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