import sys input = sys.stdin.readline def MI(): return map(int, input().split()) n,d=MI() ws=[i+1 for i in range(n)] xs=[i+1 for i in range(n)] ys=[i+1 for i in range(n)] zs=[i+1 for i in range(n)] wz,xy=[],[] for i in ws: for j in zs: wz.append(i**2-j**2+d) wz=sorted(wz) for i in xs: for j in ys: xy.append(i**2+j**2) xy=sorted(xy) from bisect import bisect_right, bisect_left ans=0 for i in xy: l=bisect_left(wz, i) r=bisect_right(wz, i) ans+=r-l print(ans)