-
Notifications
You must be signed in to change notification settings - Fork 0
/
Codeforces 1141A.cpp
41 lines (38 loc) · 983 Bytes
/
Codeforces 1141A.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <bits/stdc++.h>
#define pb push_back
#define pob pop_back
#define fp first
#define sp second
#define mp make_pair
#define ins insert
#define uEdge(u, v) g[u].pb(v), g[v].pb(u)
#define uwEdge(u, v, w) g[u].pb({v, w}), g[v].pb({u, w})
#define dEdge(u, v) g[u].pb(v)
#define dwEdge(u, v, w) g[u].pb({v, w})
#define BOOST ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define minHeap int, vector<int>, greater<int>
using namespace std;
typedef long long int lli;
typedef pair<int, int> pii;
vector<int> g[0];
lli gcd(lli a, lli b){
if(b == 0) return a;
a%=b;
return gcd(b, a);
}
int main(){
lli n, m, divi;
int cnt = 0;
scanf("%lld %lld", &n, &m);
if(m % n) printf("-1");
else{
divi = m / n;
while(!(divi % 2) || !(divi % 3)){
if(!(divi % 2)) divi/=2, cnt++;
else if(!(divi % 3)) divi/=3, cnt++;
}
if(divi != 1) printf("-1");
else printf("%d", cnt);
}
return 0;
}