#include<bits/stdc++.h>
using namespace std;

int a, p, q, n;

int gcd(int x, int y) {
	if (y == 0) return x;
	return gcd(y, x%y);
}

int search(int np, int nq, int nn, int now, int aa){
	//cout << np << "\t" << nq << "\t" << nn << "\t" << now << "\t" << aa << endl;
	if (nq * p - np * q == 0) return 1;
	else if (nq * p - np * q < 0 || nn < 1) return 0;

	int result = 0;
	for (int i = now; i * aa <= a; i++){
			result += search(np * i + nq, nq * i,nn - 1, i, i * aa);
		
	}

	return result;
}

int main(void){

	while (cin >> p >> q >> a >> n, p, q, a, n){

		cout << search(0, 1, n, q / p, 1) << endl;

	}

	return 0;
}

/*
for(i=0;i<N;i++){
cin >> X[i];
}


for(i=0;i<N;i++){
for(j=0;j<N;j++){
cin >> X[i][j];
}
}
*/