#include <iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<vector>
#include<queue>
#include<string>
#define mod 1000000007
using namespace std;
typedef long long ll;
const int maxn=305;
const int inf=0x3f3f3f3f;
int money[20];
int dp[maxn];
int main()
{
for(int i=0;i<17;i++){
money[i]=(i+1)*(i+1);
}
memset(dp,0,sizeof(dp));
dp[0]=1;
for(int i=0;i<17;i++){
for(int j=money[i];j<maxn;j++){
dp[j]=dp[j]+dp[j-money[i]];
}
}
int n;
while(scanf("%d",&n),n){
printf("%d\n",dp[n]);
}
return 0;
}