#include #include #include #include #include #include #include #include #include #include #include #include #include #include #define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl; #define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl; template inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } using namespace std; typedef long long ll; template vector> vec2d(int n, int m, T v){ return vector>(n, vector(m, v)); } template vector>> vec3d(int n, int m, int k, T v){ return vector>>(n, vector>(m, vector(k, v))); } template void print_vector(vector v, char delimiter=' '){ if(v.empty()) { cout << endl; return; } for(int i = 0; i+1 < v.size(); i++) cout << v[i] << delimiter; cout << v.back() << endl; } using mint = atcoder::modint998244353; ostream& operator<<(ostream& os, const mint& m){ os << m.val(); return os; } vector f(int n){ vector v; for(int x = 1; x*x <= n; x++){ v.push_back(x); if(x*x != n) v.push_back(n/x); } sort(v.begin(), v.end()); return v; } mint inv6 = mint(6).inv(); mint inv2 = mint(2).inv(); mint sum(int n){ return mint(n)*mint(n+1)*inv2; } mint sum_sect(int l, int r){ return sum(r)-sum(l-1); } mint sum_square(int n){ return mint(n)*mint(n+1)*mint(2*n+1)*inv6; } // [l, r] mint sum_square_sect(int l, int r){ return sum_square(r)-sum_square(l-1); } int main(){ ios::sync_with_stdio(false); cin.tie(0); cout << setprecision(10) << fixed; int n, m; cin >> n >> m; mint ans = mint(n)*mint(n+1)*mint(m)/2; auto v = f(n+1); reverse(v.begin(), v.end()); int pre = 0; for(int x: v){ int l = pre+1; int r = (n+1)/x; chmin(r, m); if(r < l) continue; ans -= sum_square_sect(l, r)*sum(x-1); ans -= sum_sect(l, r)*(n+1)*x; ans += sum_square_sect(l, r)*x*x; pre = r; } cout << ans << endl; }