# coding: utf-8 # Your code here! n,d=map(int,input().split()) # x*x + y*y = w*w + D - z*z left=[0 for i in range(n*n+n*n+1)] for x in range(1,n+1): for y in range(1,n+1): left[x*x+y*y]+=1 right=[0 for i in range(0,n*n-0+d+1)]# 0未満は切り捨て for w in range(1,n+1): for z in range(1,n+1): if w*w-z*z+d>=0: right[w*w-z*z+d]+=1 result=0 for i in range(min(n*n+n*n+1,n*n-0+d+1)): result+=(left[i]*right[i]) # print(left,right) print(result)