#include <iostream>
using namespace std;

int main() {
  while(1) {
    int n;
    cin>>n;
    if(n==0) break;
    int dp[301] = {1};
    for(int i=1;i*i<=n;i++) 
      for(int j=i*i;j<=n;j++) dp[j] += dp[j-i*i];
    cout << dp[n] <<endl;
  }
return 0;
}