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