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