#include <stdio.h>

int p, q, a, n;

int search(int p, int q, int a, int n, int x) {
	int count = 0, i;

	if (p == 0) {
		return 1;
	}
	if (n <= 0) {
		return 0;
	}

	for (i = x; i <= a; i++) {
		if (q <= i * p) {
			count += search(p * i - q, q * i, a / i, n - 1, i);
		}
	}
	return count;
}


int main(void) {
	while (1) {
		int count = 0;
		scanf("%d %d %d %d", &p, &q, &a, &n);

		if (p == 0 && q == 0 && a == 0 && n == 0) {
			break;
		}

		count = search(p, q, a, n, 1);
		printf("%d\n", count);
	}
	return 0;
}