import java.io.*;
import java.util.*;

public class formula_gk {
    static Scanner in;
    static PrintWriter out;

    final int MAX_LENGTH = 1000;
    final int MAX_VARS = 20;

    String formula;
    int pos;
    char token;
    int[] op = new int[MAX_LENGTH];
    int[] op1 = new int[MAX_LENGTH];
    int[] op2 = new int[MAX_LENGTH];

    boolean[] values = new boolean[MAX_LENGTH];
    boolean[] varValues = new boolean[MAX_VARS];
    int ops = 0;
    int root = 0;
    boolean[][] cache = new boolean[2 * MAX_VARS][2 * MAX_VARS];

    List<String> vars = new ArrayList<String>();

    public int addOp(int op, int op1, int op2) {
        this.op[ops] = op;
        this.op1[ops] = op1;
        this.op2[ops] = op2;
        return ops++;
    }

    public int addVariable(String var) {
        if (!vars.contains(var)) {
            vars.add(var);
        }
        return vars.indexOf(var);
    }

    public void nextToken() {
        while (pos < formula.length() && formula.charAt(pos) == ' ') {
            pos++;
        }
        if (pos < formula.length()) {
            token = formula.charAt(pos);
            pos++;
        } else {
            token = 0;
        }
    }

    public int parseTerm() {
        if (token == '~') {
            nextToken();
            return addOp(3, parseTerm(), 0);
        } else if (token == '(') {
            nextToken();
            int result = parseOr();
            nextToken();
            return result;
        } else if (Character.isLetter(token)) {
            String var = "" + token;
            nextToken();
            return addOp(4, addVariable(var), 0);
        } else {
            throw new RuntimeException("" + token);
        }
    }

    public int parseAnd() {
        int op1 = parseTerm();
        while (token == '&') {
            nextToken();
            op1 = addOp(2, op1, parseTerm());
        }
        return op1;
    }

    public int parseOr() {
        int op1 = parseAnd();
        while (token == '|') {
            nextToken();
            op1 = addOp(1, op1, parseAnd());
        }
        return op1;
    }

    String toBinaryString(int n, int size) {
        String result = "";
        while (size-- > 0) {
            result += n & 1;
            n >>= 1;
        }
        return result;
    }

    public class Table {
        final boolean[] table;
        final int[] vars;

        public Table(int[] vars, boolean[] table) {
            this.vars = vars;
            this.table = table;
        }

        public Table(int var, Table c0, Table c1) {
            vars = new int[c1.vars.length + 1];
            for (int i = 0; i < c1.vars.length; i++) {
                vars[i] = c1.vars[i];
            }
            vars[c1.vars.length] = var;

            table = new boolean[1 << vars.length];
            for (int i = 0; i < c1.table.length; i++) {
                table[i] = c0.table[i];
                table[i + c1.table.length] = c1.table[i];
            }
        }

        public void print() {
            for (int var : vars) {
//                System.out.print(formula_gk.this.vars.get(var));
            }
  //          System.out.println();
            for (int i = 0; i < table.length; i++) {
    //            System.out.println(toBinaryString(i, vars.length) + " " + table[i]);
            }
      //      System.out.println();
        }
        
        Table[] split(int var) {
            int v = -1;
            for (int i = 0; i < vars.length; i++) {
                if (var == vars[i]) {
                    v = i;
                }
            }
            if (v < 0) throw new RuntimeException("" + var);

            int[] l = new int[2];
            boolean[][] tbl = new boolean[2][table.length / 2];

            for (int i = 0; i < table.length; i++) {
                int s = (i >> v) & 1;
                tbl[s][l[s]++] = table[i];
            }

            int[] childVars = new int[vars.length - 1];
            int j = 0;
            for (int i = 0; i < vars.length; i++) {
                if (v != i) {
                    childVars[j++] = vars[i];
                }
            }
            return new Table[]{
                new Table(childVars, tbl[0]), 
                new Table(childVars, tbl[1])
            };
        }

        boolean less(Table that) {
            boolean result = true;
            for (int i = 0; i < table.length; i++) {
                result &= !this.table[i] || that.table[i];
            }
            return result;
        }

        boolean greater(Table that) {
            boolean result = true;
            for (int i = 0; i < table.length; i++) {
                result &= this.table[i] || !that.table[i];
            }
            return result;
        }

        Table simplify() {
            for (int i = 0; i < vars.length; i++) {
                Table[] c = split(vars[i]);
                for (int j = i + 1; j < vars.length; j++) {
                    if (!cache[vars[i]][vars[j]]) {
                        //cache[vars[i]][vars[j]] = true;
                        Table[][] q = new Table[][] {
                            c[0].split(vars[j]),
                            c[1].split(vars[j])
                        };
                        if (q[0][0].greater(q[0][1]) && q[0][0].greater(q[1][0])) {
                            int v = addVariable("(" + formula_gk.this.vars.get(vars[i]) + "&" + formula_gk.this.vars.get(vars[j]) + ")");
                            return new Table(v, q[0][0], q[1][1]);
                        }
                        if (q[1][1].less(q[0][1]) && q[1][1].less(q[1][0])) {
                            int v = addVariable("(" + formula_gk.this.vars.get(vars[i]) + "|" + formula_gk.this.vars.get(vars[j]) + ")");
                            return new Table(v, q[0][0], q[1][1]);
                        }
                    }
                }
            }
       //     System.out.println("Non repeat free");
            return null;
        }
    }

    public void run() {
        formula = in.nextLine();
        pos = 0;
        nextToken();

        root = parseOr();        
        if (token != 0) {
            throw new RuntimeException("" + token);
        }

        boolean[] tbl = new boolean[1 << vars.size()];
        for (int i = 0; i < 1 << vars.size(); i++) {
            for (int j = 0; j < vars.size(); j++) {
                varValues[j] = ((i >> j) & 1) == 1;
            }
            for (int j = 0; j < ops; j++) {
                switch (op[j]) {
                    case 1:
                        values[j] = values[op1[j]] || values[op2[j]];
                        break;
                    case 2:
                        values[j] = values[op1[j]] && values[op2[j]];
                        break;
                    case 3:
                        values[j] = !values[op1[j]];
                        break;
                    case 4:
                        values[j] = varValues[op1[j]];
                        break;
                    default:
                        throw new RuntimeException("" + op[j]);
                }
            }
            tbl[i] = values[root];
        }
        int[] v = new int[vars.size()];
        for (int i = 0; i < v.length; i++) {
            v[i] = i;
        }

        boolean ok = true;
        Table table = new Table(v, tbl);
        for (int i = 0; i < vars.size(); i++) {
            Table[] children = table.split(i);
            boolean less = children[0].less(children[1]);
            boolean greater = children[0].greater(children[1]);
            if (less && greater) {
                //System.out.println("Redundant " + vars.get(i));
                table = children[0];
            } else if (!less && !greater) {
      //          System.out.println("Non monotonic");
                ok = false;
                break;
            } else if (greater) {
                vars.set(i, "~" + vars.get(i));
                table = new Table(i, children[1], children[0]);
            }
        }

        if (table.vars.length == 0) {
            ok = false;
        }

        if (ok) {
            while (table.vars.length > 1) {
                table = table.simplify();
                if (table == null) {
                    ok = false;
                    break;
                }
            }
        }

        if (ok) {
            out.println("Yes");
            out.println(vars.get(table.vars[0]));
        } else {
            out.println("No");
        }
    }

    public static void main (String[] args) throws IOException {
        in = new Scanner(System.in);
        out = new PrintWriter(System.out);

        new formula_gk().run();

        in.close();
        out.close();
    }
}
