#include<cstdio>
#include<algorithm>
#define ll long long
#define N 10000000
using namespace std;
int read_p,read_ca;
inline int read(){
read_p=0;read_ca=getchar();
while(read_ca<‘0‘||read_ca>‘9‘) read_ca=getchar();
while(read_ca>=‘0‘&&read_ca<=‘9‘) read_p=read_p*10+read_ca-48,read_ca=getchar();
return read_p;
}
const int MOD=20101009;
int n,m,t,mu[N+1],p[N],num=0,mmh,ni,mi;
bool bo[N+1];
inline int f(int x){return 1LL*x*(x+1)/2%MOD;}
inline int min(int a,int b){return a<b?a:b;}
inline int M(int x){while (x>=MOD) x-=MOD;while (x<0) x+=MOD;return x;}
inline int MMH(int n,int m){
int mmh=0;
for (register int i=1,j=0;i<=n;j=i++) i=min(n/(ni=n/i),m/(mi=m/i)),mmh=(1LL*f(ni)*f(mi)%MOD*M(mu[i]-mu[j])+mmh)%MOD;
return mmh;
}
int main(){
n=read();m=read();
if (n>m) swap(n,m);
register int i,j;
mu[1]=1;
for (i=2;i<=m;i++){
if (!bo[i]) p[++num]=i,mu[i]=-1;
for (j=1;j<=num&&p[j]*i<=m;j++){
bo[i*p[j]]=1;
if (i%p[j]) mu[i*p[j]]=-mu[i];else{
mu[i*p[j]]=0;
break;
}
}
}
for (i=1;i<=m;i++) mu[i]=M(1LL*mu[i]*i*i%MOD+mu[i-1]);
for (int i=1,j=0;i<=n;j=i++) i=min(n/(n/i),m/(m/i)),mmh=(1LL*M(f(i)-f(j))*MMH(n/i,m/i)+mmh)%MOD;
printf("%d\n",mmh);
}