n, d = [int(i) for i in input().rstrip().split()] sqr = [i**2 for i in range(n + 1)] ans_w2_d = [i + d for i in sqr] count = 0 for x in range(1,n + 1): sqr_x = sqr[x] for y in range(1,n + 1): sqr_xy = sqr_x + sqr[y] for z in range(1,n + 1): sqr_xyz = sqr_xy + sqr[z] if sqr_xyz in ans_w2_d: w = ans_w2_d.index(sqr_xyz) #print('x:{0} y:{1} z:{2} in w{3}'.format(x,y,z,w)) count += 1 #input() print(count)