R = 2**15+1
dp = [[0]*R for i in range(4)]
for i in range(1,182):
	dp[0][i**2] += 1
for k in range(1,4):
	for i in range(1,182):
		for j in range(i**2,R-i**2):
			dp[k][j+i**2] += dp[k-1][j]

while 1:
	n = input()
	if n == 0: break
	print sum(dp[i][n] for i in range(4))