#include using namespace std; typedef long long ll; bool is_sq(ll N){ ll n = sqrtl(N); while(n * n > N) n--; while(n * n < N) n++; return n * n == N; } int main(){ ll N, K; cin >> K >> N; vector ans; for(ll x = 1; x < 320; x++){ for(ll y = 1; y < 10000; y++){ ll w = x * x * x * x * x * x + y * y * y * y; if(w > N) break; if(w % K == 0 && is_sq(w / K)) ans.emplace_back(w / K); } } sort(ans.begin(), ans.end()); ans.erase(unique(ans.begin(), ans.end()), ans.end()); cout << ans.size() << endl; return 0; }