#include<cmath>
#include<cstdio>

using namespace std;

const double EPS=1e-9;

int a,n;
double p,q;

int dfs(int i,int cnt,double sum,int prod){
	if(abs(sum-p/q)<EPS) return 1;
	if(sum+(n-cnt)*1.0/i+EPS<p/q || p/q<sum-EPS || cnt+1>n || prod*i>a) return 0;
	return dfs(i,cnt+1,sum+1.0/i,prod*i)+dfs(i+1,cnt,sum,prod);
}

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