#include <cstdio>
#include <algorithm>
#include <map>
#define rep(i,l,r) for (int i=l;i<=r;++i)
typedef long long LL;
const int INF=~0U>>2;
typedef std::pair<int,int> PII;
int exgcd(int a,int b,int &x,int &y){
if (!b){x=1,y=0;return a;}
int g=exgcd(b,a%b,x,y),t=x;
x=y;y=t-a/b*y;
return g;
}
PII range(int A,int B,int C){
if (B==0) return PII(-INF,INF);
if (B<0) A=-A,B=-B,C=-C,std::swap(A,C);
return PII((A-1)/B+1,C/B);
}
int calc(int A,int B,int C,int x1,int x2,int y1,int y2){
int x0,y0;
int G=exgcd(A,B,x0,y0);
if (C%G) return 0;
x0=C/G*x0,y0=C/G*y0;
A/=G,B/=G,C/=G;
PII X=range(x1-x0,B,x2-x0);
PII Y=range(y1-y0,-A,y2-y0);
if (X.first>X.second||Y.first>Y.second) return 0;
if (X.second<Y.second) std::swap(X,Y);
if (Y.second<X.first) return 0;
if (Y.first>X.first) return Y.second-Y.first+1;
else return Y.second-X.first+1;
}
int n,m;
int main(){
freopen("diamond.in","r",stdin);
freopen("diamond.out","w",stdout);
scanf("%d%d",&n,&m);
LL res=0;
rep(x,1,n) rep(y,1,m){
int tp=0;
int i=x,j=y;
if (i>j) std::swap(i,j);
tp+=calc(2*j,-2*i,j*j-i*i,1,j-1,1,i-1);
tp+=calc(2*j,-2*i,j*j-i*i,0,(j-1)/2,0,(i-1)/2)*2;
if (i==j) tp--;
res+=(LL)(n-x+1)*(m-y+1)*(tp);
}
printf("%I64d\n",res);
}