#include using namespace std; #ifdef LOCAL #include "settings/debug.cpp" #else #define Debug(...) void(0) #endif #define rep(i, n) for (int i = 0; i < (n); ++i) using ll = long long; using ull = unsigned long long; inline bool is_sqr(ll x) { ll s = sqrt(x); for (ll i = s - 5; i <= s + 5; ++i) { if (i * i == x) return true; } return false; } int main() { cin.tie(nullptr)->sync_with_stdio(false); ll k, n; cin >> k >> n; set cand; for (ll x = 1; x * x * x * x * x * x <= n; ++x) { for (ll y = 1; y * y * y * y <= n; ++y) { ll a = x * x * x * x * x * x + y * y * y * y; if (a > n) break; cand.insert(a); } } int ans = 0; for (ll x : cand) if (x % k == 0 && is_sqr(x / k)) ++ans; cout << ans << '\n'; return 0; }