#include <bits/stdc++.h>

using namespace std;

#define MAX 514

int main()
{
    int N;
    int dp[MAX] = {};
    dp[0] = 1;
    for (int i = 1; i <= 17; i++) {
        for (int j = 0; j < MAX-i*i; j++) {
            dp[j+i*i] += dp[j];
        }
    }
    
    while (cin >> N, N) {
        cout << dp[N] << endl;
    }
    return 0;
}