//ACSL Competition 3 by Vaibhav Janardhan


import java.util.*;

public class Veitch
{
//This boolean indicates if the veitch square value is equal to 1 or 0
    private boolean[][] value = new boolean [2][4];
//Terms stores the veitch expressions.
    private String terms;

	Veitch(String stringValue){
	    populateValue(stringValue);
	    terms = "";
	}
//This sets the values of veitch squares
	private void populateValue(String stringValue)
	{
	    int i=Integer.parseInt(stringValue,16);
	    for (int row = 1; row >= 0; row--)
	    {
	        for (int col = 3; col >= 0; col--)
	        {
	            value[row][col] = i%2 == 1;
	            i = i/2;
	        }
	    }
	}
//Setting the designated variables to their value
	Veitch(String inputTerms, String stringValue)
	{
	    terms = inputTerms;
	    populateValue(stringValue);
	    
	}
//Tells if corresponding veitch squares match
	boolean match(Veitch other)
	{
	    for (int row = 1; row >= 0; row--)
	    {
	        for (int col = 3; col >= 0; col--)
	        {
	            if (other.value[row][col] == true)
	            {
	                if (value[row][col] == false)
	                   return false;
	            }
	        }
	    }
	    return true;
	}
//removes squares if they match
	boolean remove(Veitch other)
	{
	    if (!match(other))
	    {
	        return false;
	    }
	    
	    for (int row = 1; row >= 0; row--)
	    {
	        for (int col = 3; col >= 0; col--)
	        {
	            if (other.value[row][col] == true)
	            {
	                value[row][col] = false;
	            }
	        }
	    }
	    return true;
	}
//Computes the terms by matching them to the list of possible combinations	
	void computeTerms()
	{
	    Iterator iterator = veitchList.iterator();
        while (iterator.hasNext()) {
            Veitch next = iterator.next();
            if (remove(next))
            {
                if (terms != "")
                   terms = terms + " + ";
                terms = terms + next.terms;
            }
        }
    
	}
	
	void printTerms()
	{
	    System.out.println("Veitch Terms: " + terms);
	}
	
	static List veitchList;
//Creates all the possible combinations
	static void initialize()
	{
	    veitchList = new ArrayList();
	    veitchList.add(new Veitch("B","F0"));
	    veitchList.add(new Veitch("~B","0F"));
	    veitchList.add(new Veitch("A","CC"));
	    veitchList.add(new Veitch("C","66"));
	    veitchList.add(new Veitch("~A","33"));
	    veitchList.add(new Veitch("~C","99"));
	    veitchList.add(new Veitch("AB","C0"));
	    veitchList.add(new Veitch("BC","60"));
	    veitchList.add(new Veitch("~AB","30"));
	    
	    
	    veitchList.add(new Veitch("A~B","0C"));
	    veitchList.add(new Veitch("~BC","06"));
	    veitchList.add(new Veitch("~A~B","03"));
	    
	    veitchList.add(new Veitch("A~C","88"));
	    veitchList.add(new Veitch("AC","44"));
		veitchList.add(new Veitch("~AC","22"));
	    veitchList.add(new Veitch("~A~C","11"));
	    
	    veitchList.add(new Veitch("B~C","90"));
	    veitchList.add(new Veitch("~B~C","09"));
	    
	    veitchList.add(new Veitch("ABC","40"));
	    veitchList.add(new Veitch("AB~C","80"));
	    veitchList.add(new Veitch("A~BC","04"));
	    veitchList.add(new Veitch("A~B~C","08"));
	    veitchList.add(new Veitch("~ABC","20"));
	    veitchList.add(new Veitch("~AB~C","10"));
	    veitchList.add(new Veitch("~A~BC","02"));
	    veitchList.add(new Veitch("~A~B~C","01"));
	}
	
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String a = scanner.next();
		Veitch.initialize();
		Veitch veitch = new Veitch(a);
		veitch.computeTerms();
		veitch.printTerms();
	}
}