a,b=map(int,input().split()) a%=12 deg_a=30*(a+b/60) deg_b=(6*b)%360 speed=11/120 time=((360+deg_a-deg_b)%360)/speed print(int(time+0.01))