### constant

MAX_N = 300
MAX_C = 17

COINS = (1..MAX_C).map{|c| c * c}

### subroutines

def count_rec(c, n)
  return $cache[c][n] if $cache[c][n]
  return ($cache[c][n] = 1) if c == 1

  sum = 0
  c2 = c * c
  n0 = n
  while n0 >= 0
    sum += count_rec(c - 1, n0)
    n0 -= c2
  end

  $cache[c][n] = sum
end

### main

$cache = (MAX_C + 1).times.map{(MAX_N + 1).times.map{nil}}
  
loop do
  n = gets.to_i
  break if n == 0

  puts count_rec(MAX_C, n)
end