A, B, C, D = map(int, input().split()) AB = 31 - A + B if C <= AB: print(1) exit() if D <= AB: print(2) exit() print(3)