#include #include using lint = long long; void solve() { lint n, m; std::cin >> n >> m; auto g = std::gcd(n, m); n /= g, m /= g; while (m % 10 == 0) m /= 10; while (n % 10 == 0) n /= 10; n %= 10; while (m % 2 == 0) { m /= 2; (n *= 5) %= 10; } while (m % 5 == 0) { m /= 5; (n *= 2) %= 10; } std::cout << (m == 1 ? n : -1) << "\n"; } int main() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); solve(); return 0; }