#include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

const double EPS = 1.0e-10;

int a, n;

int solve(int curr, double rest, int a2, int n2)
{
    if(a2 > a || n2 > n)
        return 0;
    if(rest < -EPS)
        return 0;
    if(rest < EPS)
        return 1;
    if(rest - (1.0 / curr) * (n - n2) > EPS)
        return 0;
    if(a2 * curr > a)
        return 0;

    int ret = solve(curr, rest - (1.0 / curr), a2 * curr, n2 + 1);
    ret += solve(curr + 1, rest, a2, n2);

    return ret;
}

int main()
{
    for(;;){
        int p, q;
        cin >> p >> q >> a >> n;
        if(q == 0)
            return 0;
        cout << solve(1, (double)p/q, 1, 0) << endl;
    }
}