#include<iostream> #include<vector> #define maxn 1000010 #define ll long long #define INF 1000000000 usingnamespacestd;
constint p = 998244353;
ll pow_mod(ll x, ll n){ ll s = 1; for (; n; n >>= 1, x = x * x % p) if (n & 1) s = s * x % p; return s; }
ll pow2[maxn]; voidinit_pow2(int n){ pow2[0] = 1; for (int i = 1; i <= n; ++i) pow2[i] = pow2[i - 1] * 2 % p; }
ll fac[maxn], inv[maxn]; voidinit_C(int n){ fac[0] = 1; for (int i = 1; i <= n; ++i) fac[i] = fac[i - 1] * i % p; inv[n] = pow_mod(fac[n], p - 2); for (int i = n - 1; ~i; --i) inv[i] = inv[i + 1] * (i + 1) % p; }
ll C(int n, int m){ return n < m ? 0 : fac[n] * inv[m] % p * inv[n - m] % p; }
int pri[maxn], cnt, phi[maxn]; bool isp[maxn]; voidinit_isp(int n){ phi[1] = 1; for (int i = 2; i <= n; ++i) { if (!isp[i]) pri[++cnt] = i, phi[i] = i - 1; for (int j = 1; j <= cnt && i * pri[j] <= n; ++j) { isp[i * pri[j]] = 1; if (i % pri[j] == 0) { phi[i * pri[j]] = phi[i] * pri[j]; break; } phi[i * pri[j]] = phi[i] * (pri[j] - 1); } } }
int n, m;
ll ans; voidsolve(int d){ ll sum = (d & 1) ? 0 : 2; for (int i = 1; i <= 1ll * m * d / n; ++i) sum = (sum + pow2[i] * (C(d - i, i) + C(d - i - 1, i - 1))) % p; ans = (ans + sum * phi[n / d]) % p; }
voidwork(){ cin >> n >> m; ans = 0; for (int p = 1; p * p <= n; ++p) { if (n % p == 0) solve(p); if (n % p == 0 && n / p != p) solve(n / p); } cout << ans * pow_mod(n, p - 2) % p << "\n"; }