#include <iostream>
using namespace std;
 
int P, Q, A, N;
int res;

void solve(int a, int n, int sum, int b) {
    if(P * a == Q * sum){
        res++;
        return;
    }
    if(P * a < Q * sum || n >= N)
        return;
 
    for(int i = b; a*i <= A; i++)
        solve(a * i, n + 1, sum * i + a, i);
}
 
int main() {
    while(cin >> P >> Q >> A >> N, P | Q | A | N) {
        res = 0;
        for(int i = 1; i <= A; i++) {
            solve(i, 1, 1, i);
        }
        cout << res << endl;
    }
}