import math a, b = map(int, input().split()) if a == 12 and b == 0: print(0) exit() if a > 12: a -= 12 s = (a/12 + b/60/12) l = b/60 speed = 1/3600 - 1/3600/12 if l > s: r = 1 - (l-s) else: r = s-l print(math.floor(r/speed))