#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; } ll num = K; ll d = 1; ll ans = 0; while (num <= N) { //cerr << d << endl; int pos = lower_bound(all(X), num) - X.begin(); rep(i, pos) { ll res = num - X[i]; if (binary_search(all(Y), res)) { ans++; //cerr << d << ' ' << X[i] << ' ' << endl; break; } } d++; num = K*d*d; } cout << ans << endl; }