a, b = map(int, input().split()) a %= 12 hun = 6 * b ji = 30 * a + b / 2 print(int(abs(ji - hun) * 60 // 5.5))