#include <iostream>
using namespace std;

int solve(int p,int q,int a,int n,int cur,int mult){
	if(n >= 0 && p == 0) return 1;
	if(n <= 0 || p <= 0) return 0;

	int res = 0;
	for(int i=cur;mult*i<=a;i++){
		res += solve(p*i-q,q*i,a,n-1,i,mult*i);
	}
	return res;
}

int main(void){
	int p,q,a,n;

	while(cin>>p>>q>>a>>n && p){
		cout<<solve(p,q,a,n,1,1)<<endl;
	}

	return 0;
}