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