A, B, C, D = map(int, input().split()) d = B + (31 - A) if d >= C: print(1) elif d >= D: print(2) else: print(3)