import sys
import bisect
square = []

i = 0
while i*i <= 2**15:
    square.append(i*i)
    i += 1

L = len(square)

while True:
    n = int(sys.stdin.readline())
    if n == 0:
        break
    count = 0
    for i in xrange(L):
        for j in xrange(i, L):
            for k in xrange(j, L):
                v = n - square[i] - square[j] - square[k]
                idx = bisect.bisect_left(square, v)
                if L > idx >= k and square[idx] == v:
                    count += 1
    print count
