#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
long long num;
long long a[250000];
long long n,m,t;
int main()
{
freopen("energy2010.in", "r", stdin);
freopen("energy2010.out", "w", stdout);
scanf("%lld%lld",&n,&m);
t=min(n,m);
for(int i=t;i>=1;--i)
{
a[i]=(long long)(n/i)*(m/i);
for(int j=2*i;j<=t;j+=i)
a[i]-=a[j];
num+=a[i]*i;;
}
printf("%lld",2*num-n*m);
//while(1);
}