#include<stdio.h>

int dfs(int p, int q, int a, int n, int pre) {
	if (p == 0) return 1;
	if (n == 0) return 0;
	int res = 0;
	for (int i = pre; i <= 12000; i++) {
		if ((a/i) == 0)break;
		res += dfs(i*p - q, i*q, a / i, n - 1, i);
	}
	return res;
}

int main() {
	int p, q, a, n;
	while (scanf("%d %d %d %d", &p, &q, &a, &n), p) {
		printf("%d\n", dfs(p, q, a, n, 1));
	}
}