#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int gcd(int a, int b) {
return b == 0 ? a : gcd(b, a % b);
}
const int mod = 998244353;
int main() {
freopen("hoip.in", "r", stdin);
freopen("hoip.out", "w", stdout);
int n, m, ans = 0;
cin >> n >> m;
for (register int i = 1; i <= n; i ++)
for (register int j = 1; j <= m; j ++) {
if (i == j) { ans += i; continue;}
ans = ((ans + gcd(i, j)) % mod + mod) % mod;
}
cout << ans << endl;
return 0;
}