A, B = map(int, input().split()) print(int((A*30+B*0.5-B*6)%360/5.5*60))