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