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