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

public class math_bm {
    FastScanner in;
    PrintWriter out;

    void solve() throws IOException {
        String s = in.br.readLine();
        ArrayList<Integer> a = new ArrayList<>();
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            if (c == '^') {
                int r = i + 1;
                while (r < s.length() && s.charAt(r) >= '0' &&  s.charAt(r) <= '9') {
                    r++;
                }
                int number= Integer.MAX_VALUE;
                if (r - i < 9) {
                    number = Integer.parseInt(s.substring(i+1, r));
                }
                a.add(number);
                i = r - 1;
            }
        }
        int last = 0;
        int n = a.size();
        for (int i =0; i < n; i++) {
            if (a.get(i) == last + 1) {
                last++;
            }
        }
        int[] from = new int[last];
        int[] to = new int[last];
        last = 0;
        for (int i = 0; i < n; i++) {
            if (a.get(i) == last + 1) {
                from[last++] = i;
            }
        }
        for (int i = n - 1; i >= 0; i--)
            if (a.get(i) == last) {
                to[--last] = i;
            }
        out.println(n);
        for (int i = 0; i < n; i++) {
            int val = a.get(i) - 1;
            if (val >= from.length || from[val] != to[val] || from[val] != i) {
                out.print("Y");
            } else {
                out.print("N");
            }
        }
        out.println();
        for (int i = 0; i < n; i++) {
            int val = a.get(i) - 1;
            if (val < from.length && from[val] <= i && to[val] >= i) {
                out.print("Y");
            } else {
                out.print("N");
            }
        }
    }

    void run() throws IOException {
        try {
            in = new FastScanner(new File("math.in"));
            out = new PrintWriter(new File("math.out"));

            solve();

            out.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
    }

    class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(File f) {
            try {
                br = new BufferedReader(new FileReader(f));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        public FastScanner(InputStream f) {
            br = new BufferedReader(new InputStreamReader(f));
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                String s = null;
                try {
                    s = br.readLine();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (s == null)
                    return null;
                st = new StringTokenizer(s);
            }
            return st.nextToken();
        }

        boolean hasMoreTokens() {
            while (st == null || !st.hasMoreTokens()) {
                String s = null;
                try {
                    s = br.readLine();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (s == null)
                    return false;
                st = new StringTokenizer(s);
            }
            return true;
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }

    public static void main(String[] args) throws IOException {
        new math_bm().run();
    }
}