A, B = map(int, input().split()) A = min(A, 12) A *= 5 A += 60/12 * (B/60) if A < B: A += 60 #print(f'{A=} {B=}') p = 60 / (60 ** 2) q = 60 / (60 * 60 * 12) ans = (A - B) / (p - q) print(f'{ans:.0f}')