def main(): N,D = map(int,input().split()) s = [i**2 for i in range(1,N+1)] c = [0]*8000001 for w in s: for z in s: a = w-z+D if a >=1: c[a] +=1 A = 0 for x in s: for y in s: A +=c[x+y] print(A) if __name__ == '__main__': main()