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