#include <stdio.h>

int memo[17][301];

int tansaku(int pos,int rest) {
	int result=0;
	int i;
	int nownumber=(17-pos)*(17-pos);
	if(pos>=17)return (rest==0)?1:0;
	if(rest<0)return 0;
	if(memo[pos][rest]>0)return memo[pos][rest]-1;
	for(i=0;rest-nownumber*i>=0;i++) {
		result+=tansaku(pos+1,rest-nownumber*i);
	}
	memo[pos][rest]=result+1;
	return result;
}

int main(void) {
	int query;
	while(1) {
		scanf("%d",&query);
		if(query==0)break;
		printf("%d\n",tansaku(0,query));
	}
	return 0;
}