a,b=map(int,input().split()) a%=12 x=(60*a+b)/2 y=b*6 d=x-y if d<0: d+=360 print(int(d/11*120))