#include #include using namespace std; using namespace boost; int main() { long N, M; cin >> N >> M; if (M % 2 && M % 5) return cout << -1 << "\n", 0; int n = to_string(N).size(); int m = to_string(M).size(); while (n < m) N *= 10, n++; while (m < n) M *= 10, m++; if (N / M == (double) N / M) return cout << N / M << "\n", 0; string ans = lexical_cast ((double) N / M + 1e-15); cout << ans.at((int) ans.find("000") - 1) << "\n"; }