#include #include #include #include #include #include #include #include #include #include using namespace std; using i64 = int64_t; template using VV = vector>; #define REP(i, n) for(i64 i = 0; i < i64(n); i++) #define REP1(i, n) for(i64 i = 1; i <= i64(n); i++) i64 INF = 100100100100100L; i64 direct[8][2] = { {1, 0}, {0, -1}, {-1, 0}, {0, 1}, {1, -1}, {-1, -1}, {-1, 1}, {1, 1} }; template ostream &operator<<(ostream &os, pair p); template ostream &operator<<(ostream &os, const vector &v) { for(i64 i = 0; i < i64(v.size()); i++) { if (i > 0) os << ' '; os << v[i]; } return os; } template ostream &operator<<(ostream &os, const set &st) { bool first = true; for(const T &it: st) if (first) { first = false; os << it; } else{ os << ' ' << it; } return os; } template ostream &operator<<(ostream &os, map &mp) { bool first = true; for(const auto &[f, l]: mp) if (first) { first = false; os << '{' << f << "-> " << l << '}'; } else{ os << ", {" << f << "-> " << l << '}'; } return os; } template ostream &operator<<(ostream &os, pair p) { os << '{' << p.first << ", " << p.second << '}'; return os; } int main() { i64 K, N; cin >> K >> N; set ans; for(i64 x = 1; x < 1'000; x++) { i64 x6 = x * x * x * x * x * x; if (x6 > N) break; for(i64 y = 1; x6 + y * y * y * y <= N; y++) { i64 num = x6 + y * y * y * y; if (num % K != 0) continue; num /= K; i64 ok = 0; i64 ng = min(num + 1, i64(100'000'010)); while (ng - ok > 1) { i64 mid = (ng + ok) / 2; if (mid * mid <= num) ok = mid; else ng = mid; } if (ok * ok == num) { ans.insert(K * ok * ok); // printf("x: %lld, y: %lld, z: %lld\n", x, y, ok); } } } cout << ans.size() << endl; return 0; }