#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
using namespace std;
typedef long long ll;
const int INF = 1<<30;
const int MOD = 1e9 + 7;
const double EPS = 1e-8;
int a, n;
int dfs(double x, double sum, int num, int limit, int step)
{
    if(abs(x - sum) <= EPS) return 1;
    if(limit == 0 || step == 0) return 0;
    int res = 0;
    for(int i = num; i <= limit; i++)
    {
        res += dfs(x, sum + 1.0 / i, i, limit / i, step - 1);
    }
    return res;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int p, q;
    while(cin >> p >> q >> a >> n, p | q | a | n)
    {
        cout << dfs((double)p / q, 0.0, 1, a, n) << endl;
    }
    return 0;
}
