#include <iostream>
#include <algorithm>

using namespace std;

int a, n, p, q;

int gcd(int x, int y){
  return (y == 0) ? x : gcd(y, x%y);
}

int lcm(int x, int y){
  return x * y / gcd(x, y);
}

int solve(int sp, int sq, int sa, int sn, int pre){
  if(sn > n) return 0;
  if(p / q < sp / sq) return 0;
  if(sp == p && sq == q) return 1;
  int res = 0;
  for(int i=pre;sa*i<=a;i++){
    int tp = 1, tq = i;
    int tmp = lcm(sq, tq);
    tp = tp * (tmp / tq) + sp * (tmp / sq);
    tq = tmp;
    tmp = gcd(tp, tq);
    res += solve(tp/tmp, tq/tmp, sa*i, sn+1, i);
  }
  return res;
}

main(){
  while(cin >> p >> q >> a >> n && (p|q|a|n)){
    int tmp = gcd(p, q), ans = 0;
    p /= tmp;
    q /= tmp;
    for(int i=1;i<=a&&n>0;i++) ans += solve(1, i, i, 1, i);
    cout << ans << endl;
  }
}