n, d = map(int, input().split()) rng = range(1, n+1) sqr = [i**2 for i in range(n + 1 )] left_dic = {(x, y): sqr[x] + sqr[y] for x in rng for y in rng} right_dic = {(z, w): sqr[w] - sqr[z] + d for w in rng for z in rng} count = 0 for left in left_dic.items(): for right in right_dic.items(): if left[1] == right[1]: count += 1 #print (left,right) print("result = " + str(count))