#yuki1236
a,b=map(int,input().split())
h=a%12*30+b/2
m=b*6
d=h-m
if d<0:
 d+=360
s=1/10-30/(60*60)
print(int(d/s))