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