N,D=map(int,input().split()) zw_list=[0]*(2*N**2+D+1) ans=0 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 for x in range(1,N+1): for y in range(1,N+1): ans+=zw_list[x**2+y**2] print(ans)