#include<stdio.h>
#define rep(i,n) for((i)=1;(i)<=(int)(n);(i)++)

int memo[301];

int main(void){
  int i,j,n,coin[18];

  rep(i,17)coin[i]=i*i;
  memo[1]=1;

  rep(i,17)rep(j,300)
    if(j>=coin[i])memo[j]+=memo[j-coin[i]];
  
  while(scanf("%d",&n),n)
    printf("%d\n",memo[n]);
  
  return 0;
}