#include using namespace std; using ll = long long; #define rep(i, n) for(int i = 0; i < n; i++) int main() { ll K, N; cin >> K >> N; int ans = 0; set st; for(ll x = 1; x * x * x * x * x * x < N; x++) { for(ll y = 1; y * y * y * y + x * x * x * x * x * x <= N; y++) { ll n = y * y * y * y + x * x * x * x * x * x; if(n % K) continue; ll d = n / K; double sq = sqrt(d); ll z = sq; if(z * z != d) continue; if(st.count(n)) continue; st.insert(n); ans++; } } cout << ans << endl; }