#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define int long long
using namespace std;
int f[10000010], ans;
int n, m;
signed main() {
freopen("hoip.in", "r", stdin);
freopen("hoip.out", "w", stdout);
scanf("%d %d", &n, &m);
if (n > m) n ^= m ^= n ^= m;
for (register int i = n; i; -- i) {
f[i] = (n / i) * (m / i);
for (register int j = 2 * i; j <= n; j += i)
f[i] -= f[j];
ans += (2 * i - 1) * f[i];
}
printf("%lld\n", ((ans + n * m) / 2) % 998244353);
return 0;
}