#include<iostream>
#include<algorithm>
using namespace std;

int rec(int p,int q,int a,int n,int last,int prod){
  if(n==0)return 0;

  int res = 0;
  for(int i=min(last,a/prod);i>=1;i--){
    if(p*i-q<=0){
      if(p*i-q==0)res++;
      return res;
    }

    int below = q*i, above = p*i-q;
    //tmp = __gcd(below,above);
    //below/=tmp; above/=tmp;
    
    res += rec(above,below,a,n-1,i,prod*i);
  }
  return res;
}
  
int main(){
  int p,q,a,n;
  while(cin >> p >> q >> a >> n,p){
    cout << rec(p,q,a,n,a,1) << endl;
  }
}