#include using namespace std; #include using namespace atcoder; using mint=modint998244353; int main(void) { long long n,m; cin >> n >> m; m=abs(m); vector fact(n+1,1); vector fact_inv(n+1,1); for(int i=1;i<=n;++i){ fact[i]=fact[i-1]*i; fact_inv[i]=fact_inv[i-1]/i; } mint ans=0; for(long long y=0;y<=n;++y){ long long x=sqrt(y*y+m); if(x*x-y*y!=m){ continue; } if(x+y>n){ continue; } if((n-x-y)%2){ continue; } long long a=x+(n-x-y)/2; long long b=(n-x-y)/2; if(a>n){ continue; } if(x && y && x!=y){ ans+=4*fact[n]*fact_inv[a]*fact_inv[n-a]*fact[n]*fact_inv[b]*fact_inv[n-b]; } else { ans+=2*fact[n]*fact_inv[a]*fact_inv[n-a]*fact[n]*fact_inv[b]*fact_inv[n-b]; } } ans/=mint(4).pow(n); cout << ans.val() << endl; return 0; }