import collections N,D=map(int, input().split()) Square = [] P = [] M = [] for i in range(N+1): Square.append(i**2) for i in range(1,N+1): for j in range(1,N+1): P.append(Square[i]+Square[j]) M.append(Square[i]-Square[j]-D) P=collections.Counter(P) M=collections.Counter(M) P = sorted( P.items() ) M = sorted( M.items() ) j = len(M)-1 ans = 0 mk,mv=M[j] for pk, pv in P: while mk+pk > 0 and j>=0: j-=1 mk,mv=M[j] if mk+pk==0: ans += mv*pv j-=1 mk,mv=M[j] print(ans)