#include<iostream>
#include<vector>
using namespace std;

int p,q,a,n;
int num;

void calc(int depth,vector<int> &hist,int max_l){
	if(depth>=n) return;
	int mul=1;
	for(int i=0;i<hist.size();i++) mul*=hist[i];

	for(int i=max_l;;i++){
		int next_mul=mul*i;
		if(next_mul>a) break;
		hist.push_back(i);
		int upper=0;
		for(int j=0;j<hist.size();j++){
			upper+=next_mul/hist[j];
		}
		if(upper*q==p*next_mul){
			num++;
		}
		if(upper*q<p*next_mul){
			calc(depth+1,hist,i);
		}
		hist.pop_back();
	}
}

int main()
{
	while(cin>>p>>q>>a>>n){
		if(p==0 && q==0 && a==0 && n==0) break;
		num=0;
		vector<int> hist=vector<int>();
		calc(0,hist,1);
		cout<<num<<endl;
	}
}