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