#include<iostream>
using namespace std;

int P,Q,A,N;

int accum(int p,int q,int depth,int dono,int prd){
  if(p==0)return 1;
  int res=0;
  for(int i=dono;prd*i<=A;i++){
    if((N-depth)*q<i*p)break;
    if(p*i<q)continue;
    res+=accum(p*i-q,q*i,depth+1,i,prd*i);
    //cout<<depth<<" "<<res<<endl;
  }
  return res;
}

int main(){
  while(cin>>P>>Q>>A>>N,A) cout<<accum(P,Q,0,1,1)<<endl;
  return 0;
}