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()) Sub = (square[:,None] - square[None,:]).flatten() + d Sub = Sub[Sub >= 0] ans = Add[Sub].sum() print(ans) if __name__ =='__main__': main()