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