#ifndef ONLINE_JUDGE #define _GLIBCXX_DEBUG #endif #include using namespace std; using ll = long long; //https://boostjp.github.io/tips/multiprec-int.html #define YES cout<<"Yes"<=0; --i) #define all(a) a.begin(),a.end() #define rall(a) a.rbegin(),a.rend() int main() { ll K, N; cin >> K >> N; vector X, Y; ll n = 1; ll x = 1; while (x <= N) { X.emplace_back(x); n++; x = n*n*n*n*n*n; } n = 1; ll y = 1; while (y <= N) { Y.emplace_back(y); n++; y = n*n*n*n; } //cerr << X.size() << ' ' << Y.size() << endl; unordered_set st; for (ll x:X) { for (ll y:Y) { st.insert(x+y); } } ll num = K; ll d = 1; ll ans = 0; while (num <= N) { //cerr << d << endl; if (st.find(num) != st.end()) ans++; d++; num = K*d*d; } cout << ans << endl; return 0; }