#include using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int64_t A, B; cin >> A >> B; if (A * B > 0) { cout << -1 << '\n'; } else { int64_t N = B; int res = 1; while (N != 0) { N = N * A + B; res++; } cout << res << '\n'; } return 0; }