// Aizu 1209: Square Coins
// 2017.9.22 bal4u@uu

#include <stdio.h>

#define N 17

int tbl[20];
int dp[20][303];

int main()
{
	int n, i, j;

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