#include <cstdio>
#include <iostream>
#define mod 998244353ll
using namespace std;
inline long long read(){
int op=1,aa=0;
char c=getchar();
while(c<'0'||c>'9'){if(c=='-')op=-1;c=getchar();}
while(c>='0'&&c<='9'){aa=aa*10+c-'0';c=getchar();}
return op*aa;
}
long long n,m;
inline long long gcd(long long x,long long y){
while(y){
long long t=x%y;
x=y;
y=t;
}
return x;
}
int main(){
freopen("hoip.in","r",stdin);
freopen("hoip.out","w",stdout);
n=read(),m=read();
// /*
long long ans=0;
for(long long i=2;i<=n;i++){
for(long long j=i+1;j<=m;j++){
ans+=gcd(i,j)%mod;
ans%=mod;
}
}
ans*=2ll;
ans+=m+n;
// */
/*
int ans=m+n;
if(m>n)swap(m,n);//令n>m
for(int i=2;i<=n;i++){
ans+=i;
}
*/
cout<<ans<<'\n';
return 0;
}