import numpy as np import sys input = sys.stdin.buffer.readline sys.setrecursionlimit(10 ** 7) N, D = map(int, input().split()) X = np.arange(1, N+1) ** 2 dpL = np.add.outer(X, X).flatten() dpR = np.subtract.outer(X, X).flatten() + D dpL = np.bincount(dpL) dpR = np.bincount(dpR[dpR >= 0]) sz = min(len(dpL), len(dpR)) ans = (dpL[:sz]*dpR[:sz]).sum() print(ans)