/*
AizuOnline A1209
Title
*/
#include <stdio.h>
// Select Below
//#include <stdlib.h>
//#include <string.h>
//#include <float.h>
//#include <math.h>
//#include <limits.h>
//Global data section

//
int square_pay(int total)
{
  square_pay_1(total,17);
}
int square_pay_1(int total,int maxcoinroot)
{
  int i,sum;
  if(total==0)
    return(1);
  if(maxcoinroot==1)
    return(1);
  sum=0;
  for(i=0;maxcoinroot*maxcoinroot*i<=total;i++)
    sum += square_pay_1(total-maxcoinroot*maxcoinroot*i, maxcoinroot-1);
  return(sum);
}

main()
{
  int t;

  while(EOF!=scanf("%d",&t) && t)
    {
      printf("%d\n",square_pay(t));
    }
return(0);
}