#include <stdio.h>

int P, Q, A, N;
int count = 0;
void solve(int n, int i, int j, int before)
{
    if (P * j < Q * i)
        return;
    else if (P / Q > i / j + (N - n))
        return;
    if (P * j == Q * i)
        count++;
    if (n < N)
    {
        for (int k = before; k <= A / j; k++)
        {
            solve(n + 1, i * k + j, j * k, k);
        }
    }
}

int main(void)
{
    while (1)
    {
        scanf("%d %d %d %d", &P, &Q, &A, &N);
        if ((P | Q | A | N) == 0)
            break;
        count = 0;
        solve(0, 0, 1, 1);
        printf("%d\n", count);
    }
}
