import std; void main() { long k, n; readf("%d %d\n", k, n); ulong[] a; foreach(x; 1..kthRooti(n, 6) + 1) { foreach(y; 1..kthRooti(n, 4) + 1) { const kz = pow(x, 6UL) + pow(y, 4UL); if(kz <= n && kz % k == 0 && isSquare(kz / k)) { a ~= kz; } } } writeln(a.sort.uniq.walkLength); } pragma(inline) ulong kthRooti(const ulong n, const int k) { if(k == 1) { return n; } const chk = (const ulong x) { ulong mul = 1; bool of; for(int i = 0; i < k; ++i) { mul = opChecked!"*"(mul, x, of); if(of) { return false; } } return mul <= n; }; ulong ret = 0; for(int i = 32; --i >= 0;) { if(chk(ret | (1UL << i))) { ret |= 1UL << i; } } return ret; } pragma(inline) bool isInt(const double n){ return n == floor(n); } pragma(inline) bool isSquare(const ulong n){ return isInt(sqrt(cast(double)n)); }