#include <stdio.h>
#include <math.h>
#include <stdlib.h>

int N, A, P, Q;

int find(int numerator, int denominator, int preIndex, int depth, int curr_a)
{
	if (depth > N || curr_a > A || numerator * Q > P * denominator)
		return 0;
	else if (numerator * Q == denominator * P)
		return 1;
	else
	{
		int counter = 0;
		for (int i = preIndex; i <= A / curr_a; i++)
		{
			counter += find(i * numerator + denominator, denominator * i, i, depth + 1, curr_a * i);
		}
		return counter;
	}
}

int main(int argc, char const *argv[])
{
	int i = 0;
	for (int p, q, a, n, out; scanf("%d %d %d %d", &p, &q, &a, &n) && a != 0; printf("%d\n", out))
	{
		out = 0;
		N = n;
		A = a;
		P = p;
		Q = q;
		out = find(0, 1, 1, 0, 1);
	}
	return 0;
}

