a,b=map(int,input().split()) d=360*(a+b/60)/12-360*b/60 if abs(d-360)<1e-7: d=0 elif d<1e-7: d+=360 ans=d/5.5*60+1e-7 print(int(ans))