import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines import numpy as np N,D = map(int,read().split()) U = 10 ** 7 sq = np.arange(1,N+1,dtype=np.int64) ** 2 xy = sq[:,None] + sq[None,:] xy_cnt = np.bincount(xy.ravel(), minlength=U) rhs = sq[:,None] - sq[None,:] + D rhs = rhs.ravel(); rhs = rhs[rhs >= 0] answer = xy_cnt[rhs].sum() print(answer)