l = list(map(str, input().split())) x, y = [], [] for c in l: if c!='?': x.append(int(c)) y.append(int(c)) else: x.append(1) y.append(4) ret = '' if min(x)==x[1] or max(x)==x[1]: ret += '1' if min(y)==y[1] or max(y)==y[1]: ret += '4' print(ret)