#include <iostream>

using namespace std;

int coin[] = {289, 256, 225, 196, 169, 144, 121, 100, 81, 64, 49, 36, 25, 16, 9, 4, 1};
   
int solve(int pay, int n) {
    if (n == 16) return 1;
    if (pay < 4) return 1;
    
    int sum = 0;
    int no_can_use = pay / coin[n];
    if (no_can_use == 0) return solve(pay, n+1);
    for (int i = 0; i <= no_can_use; i++) {
        sum += solve(pay - coin[n] * i, n+1);
    }

    return sum;
}

int main() {
    int n;
    while (cin >> n) {
        if (n == 0) break;
        cout << solve(n, 0) << endl;
    }
    return 0;
}