import java.io.*; import java.util.*; public class Main_yukicoder632 { private static Scanner sc; private static Printer pr; private static void solve() { char c1 = sc.next().toCharArray()[0]; char c2 = sc.next().toCharArray()[0]; char c3 = sc.next().toCharArray()[0]; if (c1 == '?' && c2 == '2') { pr.println(4); } else if (c1 == '?' && c2 == '3') { pr.println(1); } else if (c1 == '2' && c2 == '?') { pr.println(14); } else if (c1 == '3' && c2 == '?') { pr.println(14); } else if (c1 == '2' && c3 == '?') { pr.println(1); } else if (c1 == '3' && c3 == '?') { pr.println(4); } } // --------------------------------------------------- public static void main(String[] args) { sc = new Scanner(System.in); pr = new Printer(System.out); solve(); pr.close(); sc.close(); } private static class Printer extends PrintWriter { Printer(PrintStream out) { super(out); } } }