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