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