A, B = map(int, input().split()) A, B = A * 60 + B, B * 12 print((A - B) % 720 * 60 // 11)