N,D=map(int,input().split()) L=[0]*(D+2*N**2) cnt=0 for i in range(1,N+1): for j in range(1,N+1): L[i**2+j**2-1]+=1 for z in range(1,N+1): for w in range(1,N+1): A=D+w**2-z**2 if A<=1: pass else: cnt+=L[A-1] print(cnt)