a,b=input().split() if a[0]=="0": a=int(a[1]) else: a=int(a) if b[0]=="0": b=int(b[1]) else: b=int(b) num1=((a*30)+(0.5*b))%360 num2=6*b if num1>num2: print(int((num1-num2)/(5.5/60))) elif num1==num2: print(0) else: num1+=360 print(int((num1-num2)/(5.5/60)))