#include <iostream>
#include <vector>
using namespace std;

int main(){
  int n, coin = 17, num = 300;
  int ans[coin + 1][num];

  for(int i=1; i<=coin; i++)
    ans[i][0] = 1;

  for(int i=1; i<=coin; i++)
    for(int j=1; j<num; j++){
      if(j < i*i)
	ans[i][j] = ans[i-1][j];
      else{
	ans[i][j] = ans[i-1][j] + ans[i][j-i*i];
      }
    }

  while(cin >> n && n)
    cout << ans[17][n] << endl;

  return 0;
}