a, b = map(int, input().split()) a = a if a < 12 else a - 12 x, ans = 30000, 0 for t in range(0, 3600): at = ((a * 5) + ((b * 60 + t) * 5 / 3600)) % 60 bt = (b * 60 + t) * (1 / 60) % 60 m = abs(at - bt) if x > m: x, ans = m, t print(ans)