a,b,c,d=map(int,input().split()) #あと何日あるか求める 12月は31日まで nokori=(31-a)+b if nokori>=c: print(1) elif nokori>=d: print(2) else: print(3)