package yukicoder.No632; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); String S = in.nextLine(); String S1 = S.replace("?", "1"); String S2 = S.replace("?", "4"); boolean flg1 = false; boolean flg2 = false; if (S1.charAt(0) > S1.charAt(2) && S1.charAt(2) < S1.charAt(4)) { flg1 = true; } if (S1.charAt(0) < S1.charAt(2) && S1.charAt(2) > S1.charAt(4)) { flg1 = true; } if (S2.charAt(0) > S2.charAt(2) && S2.charAt(2) < S2.charAt(4)) { flg2 = true; } if (S2.charAt(0) < S2.charAt(2) && S2.charAt(2) > S2.charAt(4)) { flg2 = true; } if (flg1 && flg2) { System.out.println("14"); } else if (flg1) { System.out.println("1"); } else if (flg2) { System.out.println("4"); } } }