#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<string>
#include<algorithm>
#define FOR(i,a,b) for(i=(a);i<=(b);i++)
#define ROF(i,a,b) for(i=(a);i>=(b);i--)
#define mmt(a,b) memset(a,b,sizeof(a))
#define pb push_back
#define MOD 20101009
#define N 10000100
#define M 1000100
#define sn 100010
using namespace std;
typedef long long LL;
typedef long double LD;
int mu[N],mk[N],prime[M],Len=0,A[sn],B[sn],c[sn],len=0,mp[N];
int G[N],sum[N];LL n,m;
void init(int n)
{
  mu[1]=1;int i,j;
  FOR(i,2,n)
  {
    if (!mp[i]) {prime[++len]=i;mu[i]=-1;mk[i]=i;mp[i]=i;}
    FOR(j,1,len)
    {
      if ((LL)i*(LL)prime[j]>n) break;
      mp[i*prime[j]]=prime[j];
      if (i%prime[j]==0) 
      {
        mk[i*prime[j]]=mk[i]*prime[j];
        mu[i*prime[j]]=0;
        break;
      }
      else {mk[i*prime[j]]=prime[j];mu[i*prime[j]]=-mu[i];}
    }
  }
}
int mulmod(int a,int b){return (LL)a*(LL)b%MOD;}
void calc_G(int n)
{
  G[1]=1;int i;
  FOR(i,2,n) 
   if (mk[i]==i) G[i]=(G[i/mp[i]]+i*mu[i])%MOD;
   else G[i]=mulmod(G[i/mk[i]],G[mk[i]]);
  FOR(i,1,n) G[i]=mulmod(G[i],i);
  sum[0]=0;
  FOR(i,1,n) sum[i]=sum[i-1]+G[i],sum[i]%=MOD;
}
LL amd2(LL a)
{
  LL b=a+1;
  if (a&1) b>>=1;else a>>=1;
  return a*b%MOD;
}
void DIV(int x,int *a,int &Len)
{
  int i,t=(int)sqrt(x);Len=0;
  FOR(i,2,t) a[++Len]=x/i+1;
  if (t*t!=x) a[++Len]=t+1;
  ROF(i,t,1) a[++Len]=i;
  FOR(i,1,Len/2) {int t=a[i];a[i]=a[Len-i+1];a[Len-i+1]=t;}
  Len=unique(a+1,a+1+Len)-a-1;
}
int main()
{
  ios::sync_with_stdio(false);
  scanf("%d %d",&n,&m);
  int t=max(n,m);init(t);calc_G(t);
  int i,Ln,Lm,p1=1,p2=1;
  DIV(n,A,Ln);
  DIV(m,B,Lm);
  while (1)
  {
    if (A[p1]<B[p2]) c[++Len]=A[p1],p1++;
    if (A[p1]>B[p2]) c[++Len]=B[p2],p2++;
    if (A[p1]==B[p2]) c[++Len]=A[p1],p1++,p2++;
    if (p1>Ln||p2>Lm) break;
  }
  FOR(i,p1,Ln) c[++Len]=A[i];FOR(i,p2,Lm) c[++Len]=B[i];
  LL ans=0;c[Len+1]=t+1;
  FOR(i,1,Len) 
  {
    LL tmp=(sum[(int)min(c[i+1]-1,(int)min(n,m))]-sum[c[i]-1]+MOD+MOD)%MOD;
    ans+=(LL)amd2(n/c[i])*(LL)amd2(m/c[i])%MOD*(LL)tmp%MOD;
    ans%=MOD;
  }
  printf("%d\n",ans);
  return 0;
}