let buf = readLine()!.split(separator: " ").map { Int($0)! } let (a, b, c, d) = (buf[0], buf[1], buf[2], buf[3]) let remine = (31 - a) + b var ans = 0 if remine >= c { ans = 1 } else if remine >= d { ans = 2 } else { ans = 3 } print(ans)