#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; constexpr int mod = 998244353; long long fac[2000005], finv[2000005], inv[2000005]; void COMinit() { fac[0] = fac[1] = finv[0] = finv[1] = inv[1] = 1; for (int i = 2; i < 2000005; i++) { fac[i] = fac[i - 1] * i % mod; inv[i] = mod - inv[mod % i] * (mod / i) % mod; finv[i] = finv[i - 1] * inv[i] % mod; } } long long COM(int n, int k){ if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % mod) % mod; } long long choose(int n,int k) { if(n < 0 || k < 0) return 0; if(n == 0) return 1; return COM(n+k-1,k-1); } long long modpow(long long a,long long b) { long long ans = 1; while(b) { if(b & 1) { (ans *= a) %= mod; } (a *= a) %= mod; b /= 2; } return ans; } void mpl(int &x,int y) { x += y; if(x >= mod) x -= mod; } int main() { COMinit(); ios::sync_with_stdio(false); cin.tie(nullptr); int N; long long M; cin >> N >> M; long long m = abs(M); vectortmp; for(long long i = 1; i*i <= m; i++) { if(m%i == 0) { tmp.push_back(i); if(i*i != m) tmp.push_back(M/i); } } int sum = 0; for(int i = 0; i < tmp.size(); i++) { long long a = tmp[i],b = M/tmp[i]; if(abs(a)%2 != N%2 || a > N || a < -N) continue; if(abs(b)%2 != N%2 || b > N || b < -N) continue; long long p1 = (a+N)/2,p2 = (N-a)/2; long long p3 = (b+N)/2,p4 = (N-b)/2; mpl(sum,COM(N,p1)*COM(N,p3)%mod); } mpl(sum,sum); cout << sum*modpow(modpow(4,N),mod-2)%mod << "\n"; }