N,D=map(int,input().split()) P=[0]*(N*N) M=[0]*(N*N) for i in range(1,N+1): for j in range(i,N+1): P[(i-1)*N+j-1]=P[i-1+N*(j-1)]=i*i+j*j M[(i-1)*N+j-1]=i*i-j*j M[i-1+N*(j-1)]=-M[(i-1)*N+j-1] from collections import Counter PC=Counter(P) MC=Counter(M) ANS=0 for p in PC: ANS+=PC[p]*MC[p-D] print(ANS)