Two little greedy bears have found two pieces of cheese in the forest of weight *a* and *b* grams, correspondingly. The bears are so greedy that they are ready to fight for the larger piece. That's where the fox comes in and starts the dialog: "Little bears, wait a little, I want to make your pieces equal" "Come off it fox, how are you going to do that?", the curious bears asked. "It's easy", said the fox. "If the mass of a certain piece is divisible by two, then I can eat exactly a half of the piece. If the mass of a certain piece is divisible by three, then I can eat exactly two-thirds, and if the mass is divisible by five, then I can eat four-fifths. I'll eat a little here and there and make the pieces equal". 

The little bears realize that the fox's proposal contains a catch. But at the same time they realize that they can not make the two pieces equal themselves. So they agreed to her proposal, but on one condition: the fox should make the pieces equal as quickly as possible. Find the minimum number of operations the fox needs to make pieces equal.
The first line contains two space-separated integers *a* and *b* (1 ≤ *a*, *b* ≤ 10<sup class="upper-index">9</sup>).
from math import *
from collections import *
from bisect import *
import heapq
import math
from itertools import permutations

def is_prime(n):

    for i in range(2,math.ceil(math.sqrt(n))):
        if(n%i==0):
            return False
    return True

def sieve(n):
    arr=[True for _ in range(n+1)]

    for i in range(2,math.ceil(math.sqrt(n))):
        if(arr[i]==True):
            for j in range(i*i,n+1,i):
                arr[j]=False

    return arr


def power(x, y, p):
    res = 1  # Initialize result

    # Update x if it is more
    # than or equal to p
    x = x % p

    if (x == 0):
        return 0

    while (y > 0):

        # If y is odd, multiply
        # x with result
        if ((y & 1) == 1):
            res = (res * x) % p

        # y must be even now
        y = y >> 1  # y = y/2
        x = (x * x) % p

    return res

def euclidean_distance(x1,y1,x2,y2):
    return sqrt(abs(x1-x2)**2+abs(y1-y2)**2)

def get_permutations(lo=0,hi=10):
    return list(permutations(range(lo,hi)))


def solve():
    # s=input()
    # n=int(input())
    # lis=list(map(int,input().split()))
    # lis2 = list(map(int, input().split()))
    x,y=list(map(int, input().split()))

    q=deque()
    q.append((x,y))
    st=set()
    st.add((str(x)+' '+str(y)))
    c=0
    while(len(q)>0):
        sz=len(q)
        # print(q)
        for _ in range(sz):
            got=q.popleft()
            x,y=got[0],got[1]
            if(x==y):
                print(c)
                return
            z=0
            for j in [2,3,5]:
                if(x%j==0 and x!=0):
                    x_=x//j
                    if(str(x_)+' '+str(y) not in st):
                        # z+=1
                        if (x_ == y):
                            print(c + 1)
                            return
                        st.add(str(x_)+' '+str(y))
                        q.append((x_,y))

            for j in [2, 3, 5]:
                if (y % j == 0 and y!=0):
                    y_ = y // j
                    if (str(x) + ' ' + str(y_) not in st):
                        # z+=1
                        if(x==y_):
                            print(c+1)
                            return
                        st.add(str(x) + ' ' + str(y_))
                        q.append((x, y_))
            # if(z==0):
            #     print(-1)
            #     return
        c+=1
    print(-1)






if __name__ == '__main__':
    n=1
    # n=int(input())
    while(n):
        n-=1
        solve()




