import numpy as np def main(): n,d = map(int,input().split()) square = np.arange(1,n + 1) ** 2 Add = np.bincount(np.add.outer(square,square).flatten(),minlength = 10 ** 7) Sub = (square[:,None] - square[None,:]).flatten() + d Sub = Sub[Sub >= 0] ans = Add[Sub].sum() print(ans) if __name__ =='__main__': main()