#include #include using namespace std; using namespace atcoder; using mint = modint998244353; //using mint = modint1000000007; typedef long long ll; typedef pair P; typedef tuple T; templatebool chmax(T& a, const T& b) { if (a < b) { a = b;return true; } else { return false; } } templatebool chmin(T& a, const T& b) { if (a > b) { a = b;return true; } else { return false; } } const int di[] = { -1,0,1,0 }; const int dj[] = { 0,-1,0,1 }; const long long INF = 9223372036854775807; const int inf = 1001001001; ll pow(int x, int n) { ll cnt = 1; for (int i = 0; i < n; i++) { cnt *= x; } return cnt; } int main(void) { ll k, n; cin >> k >> n; set s; for (ll x = 1; x * x * x * x * x * x <= n; x++) { for (ll y = 1; y * y * y * y <= n; y++) { ll sum = x * x * x * x * x * x + y * y * y * y; if (sum > n)break; if (sum % k != 0)continue; long double m = sum / k; ll z = sqrt(m); if (z * z == m)s.insert(sum); } } cout << s.size() << "\n"; } //overflow,out_of_range