#include #define rep(i, n) for (int i = 0; i < (int) n; i++) #define repb(i, n) for (int i = (int) n; i >= 0; i--) #define reps(i, m, n) for (int i = (int) m; i < (int) n; i++) #define repsb(i, m, n) for (int i = (int) m; i >= (int) n; i--) #define SORT(v, n) sort(v, v + n); #define VSORT(v) sort(v.begin(), v.end()); # define pb(a) push_back(a) #define ll long long int int dy[] = { 0, 0, 1, -1, 0 }; int dx[] = { 1, -1, 0, 0, 0 }; const ll LLINF = 1e18 + 10; template < class T > bool chmax(T & a,const T & b) { if (a < b) { a = b; return 1; } return 0; } template < class T > bool chmin(T & a,const T & b) { if (b < a) { a = b; return 1; } return 0; } //vector> vec(n_rows, vector(n_cols, value)); using namespace std; int main(int argc, char const * argv[]){ ll a, b,n; n = 0; int ans=-1; cin >> a >> b; rep(i,100000000){ n *= a; n += b; if(n==0){ ans = i+1; break; } if (abs(n)>LLINF){ ans = -1; break; } } cout<