//Number 1209

#include <stdio.h>
#define MAX 300

int main(void)
{
  int n, i, j;
  int coin[18];
  int count[MAX+1] = {0};
      
  for(i=1; i<18; i++)   //square coin
    coin[i] = i*i;
  
  count[0] = 1;
  
  for(i=1; i<18; i++)
    {
      for(j=coin[i]; j<MAX+1; j++)
	{
	  count[j] += count[j-coin[i]];
	}
    }

  while(1)
    {
      scanf("%d", &n);
      if(n==0)
	break;
      
      printf("%d\n", count[n]);
    }

  return 0;
}

  