1 #include<bits/stdc++.h>
2 using namespace std;
3 #define LL long long
4 LL Gcd(int aa,int bb){if(bb==0)return aa;else return Gcd(bb,aa%bb);}
5 int main()
6 {
7 LL n,m,k,k1,ans,i,j,tot=0;
8 scanf("%lld %lld",&n,&m);
9 k=(n+1)*(m+1);
10 ans=k*(k-1)*(k-2)/6;
11 for(i=1;i<=n;i++)
12 {
13 for(j=1;j<=m;j++)
14 {
15 k=Gcd(i,j);
16 if(k>=2)tot+=(k-1)*(n-i+1)*(m-j+1);
17 }
18 }
19 n++;m++;
20 k=m*(m-1)*(m-2)/6;
21 k1=n*(n-1)*(n-2)/6;
22 ans-=(n*k+m*k1);
23 printf("%lld",ans-tot*2);
24 fclose(stdin);
25 fclose(stdout);
26 return 0;
27 }