#include <iostream>
#include <cstring>

using namespace std;

int main(){
    int dp[18][310];
    memset(dp, 0, sizeof(dp));

    dp[0][0] = 1;
    for(int i=1; i <= 17; i++){
        for(int j=0; j < 300; j++){
            if(i*i <= j) dp[i][j] = dp[i][j-i*i];
            dp[i][j] += dp[i-1][j];
        }
    }

    int n;
    while(cin >> n, n) cout << dp[17][n] << endl;
}