c = input() def iskadomatsu(c): if c.index(max(c)) == 1 or c.index(min(c)) == 1: return True else: return False if iskadomatsu(list(map(int, c.replace("?", "1").split()))) and list(map(int, c.replace("?", "4").split())): print(14) elif iskadomatsu(list(map(int, c.replace("?", "1").split()))): print(1) elif iskadomatsu(list(map(int, c.replace("?", "4").split()))): print(4)