def solve(n, k, t)
  return 1 if n == 0
  return 0 if k == 0
  ret = 0
  t.downto(t/k) do |x|
    ret += solve(v = n - x * x, k - 1, x * x < v ? x : Math.sqrt(v).to_i)
  end
  ret
end

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