#ifndef LOCAL #include using namespace std; #define debug(...) (void(0)) #else #include "algo/debug.h" #endif vector> Quotients(int64_t N) { vector> res; int64_t l = 1; while(l <= N) { int64_t p = N / l; int64_t r = N / p + 1; res.push_back({p, l, r}); l = r; } return res; } #include using mint = atcoder::modint998244353; const mint inv2 = mint(2).inv(); mint arith(mint a0, mint d, mint len) { return (a0 * 2 + (len - 1) * d) * len * inv2; } void solve() { int64_t N, M; cin >> N >> M; auto qq = Quotients(M); qq.push_back({0, qq.back()[2], N + 1}); mint ans = 0; for(const auto&[p, l, r]: qq) { ans += arith(M % l, -p, min(N + 1, r) - l); if(N < r) break; } 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(); } }