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