#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;

int dp[301][18];
int solve(int amount, int num) {
  // cerr << "solve(" << amount << "," << num << ")" << endl;
  if(amount == 0) return 1;
  if(num < 0) return 0;
  int &res = dp[amount][num];
  if(res != -1) return res;
  res = 0;
  for(int k = num; k >= 1; --k) {
    if(amount - k*k >= 0) res += solve(amount - k*k, k);
  }
  return res;
}

int main() {
  memset(dp, -1, sizeof(dp));
  while(true) {
    int N; cin >> N;
    if(N == 0) break;
    cout << solve(N, 17) << endl;
  }
}