#include "bits/stdc++.h" using namespace std; typedef long long Int; #define REP(i,n) for(int (i)=0;(i)<(int)(n);++(i)) Int gcd(Int a, Int b) { return b == 0 ? a : gcd(b, a % b); } int f(int n, int p) { int c = 0; while (n > 0 && n % p == 0) { n /= p; c++; } return c; } Int N, M; int main() { cin >> N >> M; Int g = gcd(N, M); N /= g; M /= g; Int m = M; int two = 0, five = 0; while (m > 0 && m % 2 == 0) { m /= 2; two++; } while (m > 0 && m % 5 == 0) { m /= 5; five++; } if (m != 1) { cout << -1 << endl; } else { Int ans = N; while (ans % 10 == 0) ans /= 10; ans %= 10; REP(i, two) { ans *= 5; while (ans % 10 == 0) ans /= 10; ans %= 10; } REP(i, five) { ans *= 2; while (ans % 10 == 0) ans /= 10; ans %= 10; } cout << ans << endl; } }