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

public class ACSL3Shubay {
    private static String returnGroups(String bin){
        int t [] [] = new int [2][4]; 
          for (int p = 0,m=0;p < 2; p++){
            for (int q = 0;q < 4; q++,m++){
            t[p][q]= Character.getNumericValue(bin.charAt(m));}
            //Create an array
          }
      String G="";
      for (int p = 0;p < 2; p++){
          for (int q = 0;q < 4; q++){
            if(t[p][q] == 1){
                if(q+1 < 4 && t[p][q+1] == 1){
                //Check the values for the array
                    
                    if(p+1 <2 && t[p+1][q] == 1 && t[p+1][q+1] == 1){
                            G  = G + "("+p + "," + q+")|("+ p + "," + (q+1) +")|("+ (p+1) + "," + q +")|("+ (p+1) + "," + (q+1) +"):";
                            t[p][q] =0;
                            t[p+1][q] =0;
                            t[p][q+1] =0;
                            t[p+1][q+1] =0;
                            //List the different combinations
                        }else{
                            G  = G + "("+p + "," + q+")|("+ p + "," + (q+1) +"):";
                            t[p][q] =0;
                            t[p][q+1] =0;
                        }
                    }else if(p==0 && q ==3 && t[0][3] ==1 && t[1][3] == 1){
                        G  = G + "("+p + "," + q+")|("+ (p+1) + "," + (q) +"):";
                            t[p][q] =0;
                            t[p+1][q] =0;
                    } else{
                        G  = G + "("+ p + "," + q +"):";
                        }
                }
          }
        }
        String tg = "";
        if(t[0][0]==1 && t[0][3] ==1&&t[1][0]==1 && t[1][3] ==1){
                            tg = G.replace("(0,0):","").replace("(0,3):","").replace("(1,0):","") ;
                            G =  "(0,0)|(0,3)|(1,0)|(1,3)" + tg ;
                            t[0][0] =0;
                            t[0][3] =0;
                            t[1][0] =0;
                            t[1][3] =0;
                            //Work out the different types of groups in the Veitch diagram
                            }
                            if(t[0][0]==1 && t[0][3] ==1){
                                tg =  G.replace("(0,0):","").replace("(0,3):","") ;
                                G = "(0,0)|(0,3):" + tg;
                                t[0][0] =0;
                            t[0][3] =0;
                            //Work out the different types of groups in the Veitch diagram

                            }
                            if(t[1][0]==1 && t[1][3] ==1){
                                tg = G.replace("(1,0):","").replace("(1,3):","");
                                G =  "(1,0)|(1,3):" + tg;
                                t[1][0] =0;
                                t[1][3] =0;
                                //Work out the different types of groups in the Veitch diagram

                            }
        //System.out.println("Final Gs" + G);
        return G;
    }
    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("\\|");
        //Name the value of the binary umbers as the letters A, B, C, D, E, F
        String xp="";
        for (String e : aExpr) 
            xp =  xp + tMap.get(e);
        xp = (xp.indexOf("A")!=-1 && xp.indexOf("D")!=-1)?xp.replaceAll("A","").replaceAll("D",""):xp;
        xp = (xp.indexOf("B")!=-1 && xp.indexOf("E")!=-1)?xp.replaceAll("B","").replaceAll("E",""):xp;
        xp = (xp.indexOf("C")!=-1 && xp.indexOf("F")!=-1)?xp.replaceAll("C","").replaceAll("F",""):xp;
        xp = xp.chars().distinct().mapToObj(c -> String.valueOf((char)c)).collect(Collectors.joining()).replace("D","~A").replace("E","~B").replace("F","~C");
        return xp;
        //Use all of the letters instead of the numbers
    }
    public static void main(String args[]) throws IOException {
        
        int iR =0, ct = 1;
        String[] inputExpression = new String[ct];
        System.out.println("Input: ");
    	while(iR < ct){
    		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            inputExpression[iR++] = br.readLine();
            //Create a buffered reader
        }
        System.out.println("Output: ");
        iR =0;
        while(iR < ct){
    	    int c =  Integer.parseInt(inputExpression[iR++], 16);
            String bry =  String.format("%1$" + 8 + "s", Integer.toBinaryString(c)).replace(' ', '0');
            String G = returnGroups(bry);
            String [] gArr = G.split(":");
            //Split the array
            Arrays.sort(gArr, Comparator.comparingInt(String::length).reversed());
            String xp = "";
            for (String s : gArr) 
                xp =  xp + "+" + getExpr(s);
            System.out.println(xp.substring(1,xp.length())); 
            //Print out the result
    	}
        
      
            
    }
    
}