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