def main(): N,D = map(int,input().split()) cnt1,cnt2 = [0 for _ in range(N**2+D)],[0 for _ in range(N**2+D)] ans =0 for x in range(1,N+1): for y in range(1,N+1): if x**2 + y**2 <= N**2+D-1: cnt1[x**2+y**2] += 1 if 2 <= (x**2 - y**2 + D) <= N**2+D-1: cnt2[x**2-y**2+D] += 1 for i,j in zip(cnt1,cnt2): ans +=i*j return ans if __name__ == '__main__': print(main())