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