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