import sys def f(a,b): return (2**a)*(5**b) def h(N): L=[2,5] X=[] for a in L: x=0 while N%a==0: N//=a x+=1 X.append(x) return X def dist(P,Q): return abs(P[0]-Q[0])+abs(P[1]-Q[1]) A,B=map(int,input().split()) G=9 P,Q=h(A),h(B) V=[(-1,0),(0,-1),(1,0),(0,1)] if dist(P,Q)%2==0: S=[7,9] while P!=S: M=dist(P,S) Y=[-1,-1] for u,v in V: R=[P[0]+u,P[1]+v] if dist(R,S)