#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(c) ((c).begin()), ((c).end())
#define sz(x) ((int)(x).size())
#ifdef LOCAL
#include <print.h>
#else
#define trace(...)
#define endl "\n" // remove in interactive
#endif
int power(int n, int p){
n /= p;
int ret = 0;
while(n){
ret += n;
n /= p;
}
return ret;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL); // Remove in interactive problems
int m; ll N;
cin >> N >> m;
m = min((ll)m, N);
vector<bool> isprime(m+1, true);
for(int p = 2; p * p <= m; p++) if(isprime[p]){
for(int q = p * p; q <= m; q += p) isprime[q] = false;
}
vector<ll> Sum(m + 1);
vector<int> tot;
vector<ll> primes;
for(int p = 2; p <= m; p++){
Sum[p] = Sum[p - 1];
if(p % 3 == 2 && isprime[p]){
primes.push_back(p);
tot.push_back(power(m, p));
Sum[p] += p;
}
}
int nump = primes.size();
const int mod = 998244353;
const ll mod2 = mod * 8LL * mod;
function<ll(ll)> get = [&](ll n){
ll ret = 2; // y = 1
function<void(ll, int, int,int)> recurse = [&](ll x, int i, int t, int e){
int p = x == 1 ? 1 : primes[i];
if(e > 0 && e < tot[i]) ret += t * x * p; // y = x * p
ret += ((3 - t) * x % mod) * ((Sum[min((ll)m, n / x)] - Sum[p]) % mod); // y = x * q, q > p
if(ret >= mod2) ret -= mod2;
ll mx = n / x;
if(primes[i] * primes[i] > mx) return;
if(e < tot[i]) recurse(x * primes[i], i, e == 0 ? 3 - t: t, e + 1);
for(int j = i + 1; j < nump && primes[j] * primes[j] <= mx; j++){
recurse(x * primes[j], j, 3 - t, 1);
}
};
recurse(1, 0, 2, 0);
return ret % mod;
};
ll ans = 0;
int maxp2 = power(m, 2);
for(ll x = 2, i = 1; x <= N && i <= maxp2; x *= 2, i++) ans += x / 2;
int maxp = power(m, 3);
for(ll x = 3, i = 1; x <= N && i <= maxp; x *= 3, i++){
ans += (get(N / x)) * ( (x / 3) % mod);
ans %= mod;
}
cout << ans << endl;
}
I2luY2x1ZGUgPGJpdH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DMgPT0gMiAmJiBpc3ByaW1lW3BdKXsKICAgICAgICAgICAgcHJpbWVzLnB1c2hfYmFjayhwKTsKICAgICAgICAgICAgdG90LnB1c2hfYmFjayhwb3dlcihtLCBwKSk7CiAgICAgICAgICAgIFN1bVtwXSArPSBwOwogICAgICAgIH0KICAgIH0KICAgIGludCBudW1wID0gcHJpbWVzLnNpemUoKTsKICAgIGNvbnN0IGludCBtb2QgPSA5OTgyNDQzNTM7CiAgICBjb25zdCBsbCBtb2QyID0gbW9kICogOExMICogbW9kOwoKICAgIGZ1bmN0aW9uPGxsKGxsKT4gZ2V0ID0gWyZdKGxsIG4pewogICAgICAgIGxsIHJldCA9IDI7IC8vIHkgPSAxCiAgICAgICAgZnVuY3Rpb248dm9pZChsbCwgaW50LCBpbnQsaW50KT4gcmVjdXJzZSA9IFsmXShsbCB4LCBpbnQgaSwgaW50IHQsIGludCBlKXsKICAgICAgICAgICAgaW50IHAgPSB4ID09IDEgPyAxIDogcHJpbWVzW2ldOwogICAgICAgICAgICBpZihlID4gMCAmJiBlIDwgdG90W2ldKSByZXQgKz0gdCAqIHggKiBwOyAvLyB5ID0geCAqIHAKICAgICAgICAgICAgcmV0ICs9ICgoMyAtIHQpICogeCAlIG1vZCkgKiAoKFN1bVttaW4oKGxsKW0sIG4gLyB4KV0gLSBTdW1bcF0pICUgbW9kKTsgLy8geSA9IHggKiBxLCBxID4gcAogICAgICAgICAgICBpZihyZXQgPj0gbW9kMikgcmV0IC09IG1vZDI7CiAgICAgICAgICAgIGxsIG14ID0gbiAvIHg7CiAgICAgICAgICAgIGlmKHByaW1lc1tpXSAqICBwcmltZXNbaV0gPiBteCkgcmV0dXJuOwogICAgICAgICAgICBpZihlIDwgdG90W2ldKSByZWN1cnNlKHggKiBwcmltZXNbaV0sIGksIGUgPT0gMCA/IDMgLSB0OiB0LCBlICsgMSk7CiAgICAgICAgICAgIGZvcihpbnQgaiA9IGkgKyAxOyBqIDwgbnVtcCAmJiBwcmltZXNbal0gKiBwcmltZXNbal0gPD0gbXg7IGorKyl7CiAgICAgICAgICAgICAgICByZWN1cnNlKHggKiBwcmltZXNbal0sIGosIDMgLSB0LCAxKTsKICAgICAgICAgICAgfQogICAgICAgIH07CiAgICAgICAgcmVjdXJzZSgxLCAwLCAyLCAwKTsKICAgICAgICByZXR1cm4gcmV0ICUgbW9kOwogICAgfTsKICAgIGxsIGFucyA9IDA7CiAgICBpbnQgbWF4cDIgPSBwb3dlcihtLCAyKTsKICAgIGZvcihsbCB4ID0gMiwgaSA9IDE7IHggPD0gTiAmJiBpIDw9IG1heHAyOyB4ICo9IDIsIGkrKykgYW5zICs9IHggLyAyOwogICAgaW50IG1heHAgPSBwb3dlcihtLCAzKTsKCiAgICBmb3IobGwgeCA9IDMsIGkgPSAxOyB4IDw9IE4gJiYgaSA8PSBtYXhwOyB4ICo9IDMsIGkrKyl7CiAgICAgICAgYW5zICs9IChnZXQoTiAvIHgpKSAqICggKHggLyAzKSAlIG1vZCk7CiAgICAgICAgYW5zICU9IG1vZDsKICAgIH0KICAgIGNvdXQgPDwgYW5zIDw8IGVuZGw7Cn0=