#include <bits/stdc++.h>   using namespace std;   const int dx[] = {-1, 0, 0, 1};   const int dy[] = {0, -1, 1, 0};   int cnt[2][10];   int main() {     int a, b;     cin >> a >> b;     while (a % 2 == 0 || a % 3 == 0 || a % 5 == 0) {       if (a % 2 == 0) {         a /= 2;         cnt[0][2]++;       }       if (a % 3 == 0) {         a /= 3;         cnt[0][3]++;       }       if (a % 5 == 0) {         a /= 5;         cnt[0][5]++;       }     }     while (b % 2 == 0 || b % 3 == 0 || b % 5 == 0) {       if (b % 2 == 0) {         b /= 2;         cnt[1][2]++;       }       if (b % 3 == 0) {         b /= 3;         cnt[1][3]++;       }       if (b % 5 == 0) {         b /= 5;         cnt[1][5]++;       }     }     if (a != b)       puts( -1 );     else {       cout << abs(cnt[0][2] - cnt[1][2]) + abs(cnt[0][3] - cnt[1][3]) +                   abs(cnt[0][5] - cnt[1][5])            << endl;     }     return 0;   }   