a, b, c, d = map(int, input().split()) p = 31 - a + b if p >= c: print(1) elif p >= d: print(2) else: print(3)