#include #include #include #include #include #include #include #include #include #include #include #include typedef long long ll; using namespace std; #define mod 1000003 #define INF 1000000000 #define LLINF 2000000000000000000LL #define SIZE 10000 int main(){ ll n,m,ans; set ss; scanf("%lld%lld",&n,&m); while(1){ if(n%m==0){ ans=n/m; while(ans%10==0) ans/=10; printf("%lld\n",ans); return 0; } n%=m; if(ss.find(n)!=ss.end()){ puts("-1"); return 0; } ss.insert(n); n*=10; } return 0; }