a, b = map(int, input().split()) print(int((720 - (60 * a + b)) * 11 % 720 * 60 / 11))