N,D=map(int,input().split()) zw_list=[0]*(2*N**2+D+1) ans=0 p_list=[] for i in range(1,N+1): p_list.append(i**2) for z in p_list: for w in p_list: cal=D-z+w if cal>0: zw_list[cal]+=1 for x in p_list: for y in p_list: ans+=zw_list[x+y] print(ans)