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