#!/usr/bin/env python3 def is_kadomatsu_sequence(xs): return len(xs) == len(set(xs)) == 3 and xs[1] in (min(xs), max(xs)) def main(): cs = input().split() i = cs.index("?") cand1 = cs[:] cand1[i] = "1" cand1 = [int(x) for x in cand1] cand4 = cs[:] cand4[i] = "4" cand4 = [int(x) for x in cand4] res = "" if is_kadomatsu_sequence(cand1): res += "1" if is_kadomatsu_sequence(cand4): res += "4" print(res) if __name__ == '__main__': main()