#include #include //小数点出力用 //cout << fixed << setprecision(10) << ans; #include #include #include #include #include #include #include #include using ll = long long; using namespace std; #define modP7 1'000'000'007 #define modP 998244353 bool chkrng0idx(int pos, int sup) { return (0 <= pos && pos < sup); } int clk4(int num) { return (num - 2) * (num % 2); } void yn(bool tf) { cout << (tf ? "Yes\n" : "No\n"); } int squareRoot(long long x) { int left = 1; int right = (int)1e8; int mid; while (right - left > 1) { mid = (right + left) / 2; if ((long long)mid * (long long)mid <= x) { left = mid; } else { right = mid; } } return left; } int main() { ll K; cin >> K; ll N; cin >> N; ll X[317]; ll Y[5624]; for (ll x = 1;x <= 316;x++) { X[x] = x * x * x * x * x * x; } for (ll y = 1;y <= 5623;y++) { Y[y] = y * y * y * y; } unordered_set ans; for (int i = 1;i <= 316;i++) { if (N < X[i])break; for (int j = 1;j <= 5623;j++) { if (N < X[i] + Y[j])break; if ((X[i] + Y[j]) % K == 0) { if ((ll)squareRoot((X[i] + Y[j]) / K) * (ll)squareRoot((X[i] + Y[j]) / K) == (X[i] + Y[j]) / K) { ans.insert(X[i] + Y[j]); } } } } cout << ans.size(); return 0; }