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

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