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