#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
using namespace std;

int dp[301][18];

int main(){
	int n;
	while(cin >> n, n){
		for(int i = 0; i <= n; i++) dp[i][1] = dp[i][0] = 1;
		for(int i = 0; i <= n; i++){
			for(int j = 2; j <= 18; j++){
				dp[i][j] = 0;
				int k;
				for(k = 0; i - k * j * j >= 0; k++){
					dp[i][j] += dp[i - k * j * j][j - 1];
				}
			}
		}
		cout << dp[n][18] << endl;
	}
}