#include #include #include #include #include #include #include #include #include #include #include using namespace std; int main(){ long long N, M, X, cnt2=0, cnt5=0, s; cin >> N >> M; if (N % M == 0){ X = N/M; while(X != 0){ if (X % 10 != 0){ cout << X % 10 << endl; return 0; } X /= 10; } } while(M % 2 == 0){ cnt2++; M /= 2; } while(M % 5 == 0){ cnt5++; M /= 5; } if (M != 1){ cout << -1 << endl; return 0; } while(N % 2 == 0 && cnt2 > 0){ cnt2--; N /= 2; } while(N % 5 == 0 && cnt5 > 0){ cnt5--; N /= 5; } if (cnt2 > 0) s = 5; else s = N % 10; while(cnt5 > 0){ s = ((s * 10) / 5) % 10; cnt5--; } cout << s << endl; return 0; }