N, A, B, C = map(int, input().split()) def func(n): return n.bit_length() == n.bit_count() A, B, C = sorted([A, B, C]) if not func(A) and not func(B) and not func(C): print(N) elif (not func(B) or A != B-1) and (not func(C) or B != C-1): ans = N for n in [A, B, C]: if func(n): a = 1<