#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define INF 100000000
#define EPS 1e-10
#define MOD 1000000007
using namespace std;

double p, q;
int a, n;

int func(double v, int st, int x, int d){
	int ret = 0;
	for(int i = st;;i++){
		if(i*x > a) break;
		if(v+1.0/i + EPS > p/q && v+1.0/i < p/q+EPS) ret++;
		else if(v+1.0/i < p/q && d < n-1){
			ret += func(v+1.0/i,i,i*x,d+1);
		}
	}
	return ret;
}

void solve(){
	cout << func(0,1,1,0) << endl;
}

int main(){
	while(true){
		cin >> p >> q >> a >> n;
		if(p == 0 && q == 0 && a == 0 && n == 0) break;
		solve();
	}
}