#include <cstdio>
using namespace std;

int main()
{
	int money[17];
	int dp[301] = {1};
	
	for (int i = 0; i < 17; i++){
		money[i] = (i + 1) * (i + 1);
	}
	
	for (int i = 0; i < 17; i++){
		for (int j = 0; j <= 300 - money[i]; j++){
			dp[j + money[i]] += dp[j];
		}
	}
	
	int n;
	while (scanf("%d", &n), n){
		printf("%d\n", dp[n]);
	}
	
	return 0;
}