import math A, B = map(int, input().split()) if A == 24: angA = 0 elif A >= 12: angA = A - 12 else: angA = A ans = 0 nowB = B * 6 nowA = angA * 30 + B * 0.5 if nowB > nowA: ans += (60 - B)* 60 nowB = 0 angA += 1 if angA == 12: angA = 0 nowA = angA * 30 if math.isclose(((nowA - nowB) / (0.1 - (0.5/60))), int(((nowA - nowB) / (0.1 - (0.5/60)))) + 1): ans += int((nowA - nowB) / (0.1 - (0.5/60))) + 1 else: ans += int((nowA - nowB) / (0.1 - (0.5/60))) print(ans) else: if math.isclose(((nowA - nowB) / (0.1 - (0.5/60))), int(((nowA - nowB) / (0.1 - (0.5/60)))) + 1): print(int((nowA - nowB) / (0.1 - (0.5/60))) + 1) else: print(int((nowA - nowB) / (0.1 - (0.5/60))))