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