#include<iostream>

#define rep(i,n) for(int i=0;i<n; i++)

int p,q,a;

int solve(int n, int i, int prob, int sum){
	int cnt = 0;
	for(; i*prob <= a; i++){
		int left = i*prob*p;
		int right = i*sum+prob;
		if(left < right*q)continue;
		if(left == right*q){cnt++;continue;}
		if(n == 1)continue;
		cnt += solve(n-1,i,prob*i,right);
	}
	return cnt;
}

int main(){

	int n;

	while(std::cin >> p >> q >> a >> n,(p||q||a||n)){
		std::cout << solve(n,1,1,0) << std::endl;
	}
	return 0;
}