#include <iostream>
#define e 0.000000001
using namespace std;
int func(int,int,double,int);
int p,q,a,n;
double k;
 
int main(){
  while(1){
    cin>>p>>q>>a>>n;
    if(!p) break;
    k=1.0*p/q;
    cout<<func(0,1,0,1)<<endl;
  }
  return 0;
}
 
int func(int x,int w,double y,int I){
  int r=0;
  if(-e<=k-y&&k-y<=e) r++;
  if(x==n||y>k+e) return r;
  for(int i=I;w*i<=a;i++) r+=func(x+1,w*i,1.0/i+y,i);
  return r;
}