A, B = map(int, input().split()) x = 12 * 60 * 60 / 11 t = (A * 60 + B) * 60 % (12 * 60 * 60) if t / x - int(t / x) < 0.001: print(0) exit() y = int(t / x) for i in range(int(x) + 1): z = int((t + i) / x) if y != z: print(i - 1) exit()