a,b=map(int,input().split()) # 5分/60=1/12分 a*=5*720 a+=b*(720*5//60) b*=720 ans=0 mod=43200 na,nb=a,b #na,nb=a%mod,b%mod pre=na>nb if na%mod==nb%mod: print(0) exit() #print((a,b),pre) for i in range(3600): na=a+i nb=b+i*(720//60) #na,nb=na%mod,nb%mod if pre!=(na>=nb):break ans=i print(ans)