#include <iostream>
#include <vector>
using namespace std;
int main(){
	vector<int> tbl;
	int dp[301] = {0};
	
	
	for(int i=1 ; i*i<= 300 ; i++)tbl.push_back(i*i);
	
	dp[0] = 1;
	
	for(int j = 0; j < tbl.size() ; j++){
		for(int co = tbl[j]; co <= 300 ; co++){
				dp[co] += dp[co-tbl[j]];
		}
	}
	int n;
	while(cin >> n , n){
		cout << dp[n] << endl;
	}
}

	