N,D=map(int,input().split()) import numpy as np xy_list=np.array([0]*(2*N**2+D+1)) zw_list=np.array([0]*(2*N**2+D+1)) for x in range(1,N+1): for y in range(1,N+1): xy_list[x**2+y**2]+=1 for z in range(1,N+1): for w in range(1,N+1): cal=D-z**2+w**2 if cal>0: zw_list[cal]+=1 print(sum(xy_list*zw_list))