from collections import * from itertools import * from functools import * from heapq import * import sys,math input = sys.stdin.readline mod = 998244353 class combination(): def __init__(self,N,p): self.fact = [1, 1] # fact[n] = (n! mod p) self.factinv = [1, 1] # factinv[n] = ((n!)^(-1) mod p) self.inv = [0, 1] # factinv 計算用 self.p = p self.N = N for i in range(2, N + 1): self.fact.append((self.fact[-1] * i) % p) self.inv.append((-self.inv[p % i] * (p // i)) % p) self.factinv.append((self.factinv[-1] * self.inv[-1]) % p) def cmb(self,n, r): if (r < 0) or (n < r): return 0 if self.N < n: r = min(n-r,r) tmp = factinv[r] for j in range(r): tmp = tmp*(n-j)%sefl.p return tmp r = min(r, n - r) return self.fact[n] * self.factinv[r] * self.factinv[n-r] % self.p N,M = map(int,input().split()) M = abs(M) def md(n): lower_divisors , upper_divisors = [], [] i = 1 while i*i <= n: if n % i == 0: lower_divisors.append(i) if i != n // i: upper_divisors.append(n//i) i += 1 return lower_divisors + upper_divisors[::-1] C = combination(N+1,mod) ans = 0 if M!=0: for p in md(M): u,v = p,M//p if ((N-u)%2==1)|((N-v)%2==1): continue if u>N: continue if v>N: continue du = (N-u)//2 dv = (N-v)//2 ans += C.cmb(N,du)*C.cmb(N,dv)*2%mod print(ans*pow(4,N*(mod-2),mod)%mod) exit() ans = 0 if N%2: print(0) exit() n = N//2 ans += C.cmb(N,n)*(2*pow(2,N,mod) - C.cmb(N,n)) %mod print(ans*pow(4,N*(mod-2),mod)%mod)