#include <stdio.h>

#define EPS (1e-7)

int p,q,a,n;

long long tansaku(double rest,int nowa,int n,int start) {
	long long result=0;
	int i;
	if(n<=0)return 0;
	i=start;
	if((long long)nowa*i>a)i=a/nowa;
	for(;i>0;i--) {
		double nextrest=rest-1.0/i;
		if(nextrest+EPS<0)break;
		else if(-EPS<nextrest && nextrest<EPS){result++;break;}
		else result+=tansaku(nextrest,nowa*i,n-1,i);
	}
	return result;
}

int main(void) {
	while(scanf("%d%d%d%d",&p,&q,&a,&n)==4 && (p|q|a|n)!=0) {
		printf("%lld\n",tansaku((double)p/q,1,n,a));
	}
	return 0;
}