#ifndef LOCAL #include using namespace std; #define debug(...) (void(0)) #else #include "algo/debug.h" #endif vector> Quotients(int64_t P) { vector> res; int64_t l = 1; while (l <= P) { int64_t p = P / l; int64_t r = P / p + 1; res.push_back({p, l, r}); l = r; } return res; } #include using mint = atcoder::modint998244353; int64_t arith(int64_t a0, int64_t d, int64_t len) { return (a0 * 2 + (len - 1) * d) * len / 2; } void solve() { int64_t N, M; cin >> N >> M; vector> qq = Quotients(M); vector thr; vector pref{0}; for (const auto& [p, l, r] : qq) { thr.push_back(l); pref.push_back(pref.back() + arith(M % l, -p, r - l)); } const auto g = [&](int r) -> int64_t { if(r <= 0) return 0; int hi = r, lo = 0; while (hi > lo + 1) { int mi = (hi + lo) / 2; (M / mi == M / r ? hi : lo) = mi; } int k = distance(thr.begin(), lower_bound(thr.begin(), thr.end(), hi)); mint ans = pref[k]; ans += arith(M % hi, -M / hi, r - hi + 1); return ans.val(); }; cout << g(N) << endl; } int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); int tt = 1; // std::cin >> tt; while (tt--) { solve(); } }