def solve(n, k, q, a)
  return 1 if n == 0
  return 0 if k == 0
  ret = 0
  t = [q, a].min
  t.downto(t/k) do |x|
    ret += solve(n - x * x, k - 1, Math.sqrt(n - x * x).to_i, x)
  end
  ret
end

while n = gets.to_i
  break if n == 0
  puts solve(n, 4, Math.sqrt(n).to_i, n)
end