import sys input = sys.stdin.readline A,B,C,D=map(int,input().split()) x=31-A+B if x>=C: print(1) elif x>=D: print(2) else: print(3)