import java.util.*;
import java.util.stream.Collectors;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class NiyatiKotturyACSLContest3 {
    private static String returnGroups(String bin){
        int tArr [] [] = new int [2][4]; 
          for (int a = 0,m=0;a < 2; a++){
            for (int b = 0;b < 4; b++,m++){
            tArr[a][b]= Character.getNumericValue(bin.charAt(m));}
          }
      String group="";
      for (int a = 0;a < 2; a++){
          for (int b = 0;b < 4; b++){
            if(tArr[a][b] == 1){
                if(b+1 < 4 && tArr[a][b+1] == 1){
                    
                    if(a+1 <2 && tArr[a+1][b] == 1 && tArr[a+1][b+1] == 1){
                            group  = group + "("+a + "," + b+")|("+ a + "," + (b+1) +")|("+ (a+1) + "," + b +")|("+ (a+1) + "," + (b+1) +"):";
                            tArr[a][b] =0;
                            tArr[a+1][b] =0;
                            tArr[a][b+1] =0;
                            tArr[a+1][b+1] =0;
                        }else{
                            group  = group + "("+a + "," + b+")|("+ a + "," + (b+1) +"):";
                            tArr[a][b] =0;
                            tArr[a][b+1] =0;
                        }
                    }else if(a==0 && b ==3 && tArr[0][3] ==1 && tArr[1][3] == 1){
                        group  = group + "("+a + "," + b+")|("+ (a+1) + "," + (b) +"):";
                            tArr[a][b] =0;
                            tArr[a+1][b] =0;
                    } else{
                        group  = group + "("+ a + "," + b +"):";
                        }
                }
          }
        }
        String tGroup = "";
        if(tArr[0][0]==1 && tArr[0][3] ==1&&tArr[1][0]==1 && tArr[1][3] ==1){
                            tGroup = group.replace("(0,0):","").replace("(0,3):","").replace("(1,0):","") ;
                            group =  "(0,0)|(0,3)|(1,0)|(1,3)" + tGroup ;
                            tArr[0][0] =0;
                            tArr[0][3] =0;
                            tArr[1][0] =0;
                            tArr[1][3] =0;
                            }
                            if(tArr[0][0]==1 && tArr[0][3] ==1){
                                tGroup =  group.replace("(0,0):","").replace("(0,3):","") ;
                                group = "(0,0)|(0,3):" + tGroup;
                                tArr[0][0] =0;
                            tArr[0][3] =0;
                            }
                            if(tArr[1][0]==1 && tArr[1][3] ==1){
                                tGroup = group.replace("(1,0):","").replace("(1,3):","");
                                group =  "(1,0)|(1,3):" + tGroup;
                                tArr[1][0] =0;
                                tArr[1][3] =0;
                            }
        //System.out.println("Final groups" + group);
        return group;
    }
    private static String getExpr(String grp){
        HashMap tMap = new HashMap();
        tMap.put("(0,0)", "ABF");
        tMap.put("(0,1)", "ABC");
        tMap.put("(0,2)", "DBC");
        tMap.put("(0,3)", "DBF");
        tMap.put("(1,0)", "AEF");
        tMap.put("(1,1)", "AEC");
        tMap.put("(1,2)", "DEC");
        tMap.put("(1,3)", "DEF");
        String [] aExpr = grp.split("\\|");
        String expr="";
        for (String e : aExpr) 
            expr =  expr + tMap.get(e);
        expr = (expr.indexOf("A")!=-1 && expr.indexOf("D")!=-1)?expr.replaceAll("A","").replaceAll("D",""):expr;
        expr = (expr.indexOf("B")!=-1 && expr.indexOf("E")!=-1)?expr.replaceAll("B","").replaceAll("E",""):expr;
        expr = (expr.indexOf("C")!=-1 && expr.indexOf("F")!=-1)?expr.replaceAll("C","").replaceAll("F",""):expr;
        expr = expr.chars().distinct().mapToObj(c -> String.valueOf((char)c)).collect(Collectors.joining()).replace("D","~A").replace("E","~B").replace("F","~C");
        return expr;
    }
    public static void main(String args[]) throws IOException {
        
        int inputRow =0, COUNT = 1;
        String[] inputExpression = new String[COUNT];
        System.out.println("Input: ");
    	while(inputRow < COUNT){
    		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            inputExpression[inputRow++] = br.readLine();
        }
        System.out.println("Output: ");
        inputRow =0;
        while(inputRow < COUNT){
    	    int c =  Integer.parseInt(inputExpression[inputRow++], 16);
            String bry =  String.format("%1$" + 8 + "s", Integer.toBinaryString(c)).replace(' ', '0');
            String group = returnGroups(bry);
            String [] gArr = group.split(":");
            Arrays.sort(gArr, Comparator.comparingInt(String::length).reversed());
            String expr = "";
            for (String s : gArr) 
                expr =  expr + "+" + getExpr(s);
            System.out.println(expr.substring(1,expr.length())); 
    	}
        
      
            
    }
    
}