import sys def MI(): return map(int,sys.stdin.readline().rstrip().split()) N,D = MI() count0 = {} count1 = {} for i in range(1,N+1): for j in range(1,N+1): a = i**2+j**2 b = -i**2+j**2+D if a in count0.keys(): count0[a] += 1 else: count0[a] = 1 if b <= 1: continue if b in count1.keys(): count1[b] += 1 else: count1[b] = 1 ans = 0 for key in count0.keys(): if key in count1.keys(): ans += count0[key]*count1[key] print(ans)