#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <string>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <queue>
#include <climits>
#include <set>
#include <complex>
#include <cmath>
#include <cstring>
#include <map>
using namespace std;
using ll = long long;
#define MOD 1000000007
#define INF 1LL << 59
const int MAX = 510000;
int P, Q, A, N;

int dfs(int p, int q, int en, int idx)
{
    if (P * q == p * Q)
        return 1;

    if (P * q < p * Q)
        return 0;
    if (en == N)
        return 0;

    int res = 0;
    for (int i = idx; q * i <= A; i++)
    {
        res += dfs(p * i + q, q * i, en + 1, i);
    }
    return res;
}

int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    //cout << fixed << setprecision(5);

    while (cin >> P >> Q >> A >> N, P || Q || A || N)
    {
        cout << dfs(0, 1, 0, 1) << endl;
    }

    return 0;
}
