#include using namespace std; typedef long long ll; bool check(ll m){ while(m % 5 == 0) m /= 5; while(m % 2 == 0) m /= 2; return m == 1; } int main(){ ll n, m; cin >> n >> m; if(!check(m)){ cout << -1 << endl; return 0; } ll ans = 0; while(n){ ans = n/m; n %= m; n *= 10; } if(ans >= 10){ ll ten = 10; while(ans%ten == 0) ten*=10; ans = (ans%ten)*10/ten; } cout << ans << endl; return 0; }