#include<iostream>
using namespace std;
int mx(int x, int n);
int euc(int x, int y);
int solve(int p, int q, int a, int n, int down);
int main(){
  int p,q,a,n;
  while(cin >>p>>q>>a>>n,p||q||a||n){
    int ans = 0;
    for(int i=1; i<=n; i++) ans+=solve(p,q,a,i,q/p);
    cout <<ans<<endl;
  }
  return 0;
}
int mx(int x, int n){
  if(n == 1) return x;
  return mx(x,n-1)*x;
}
int euc(int x, int y){
  if(y == 0) return x;
  return euc(y,x%y);
}
int solve(int p, int q, int a, int n, int down){
  if(n == 1 && q%p == 0 && q/p<=a && down<=q/p) return 1;
  int ans = 0;
  for(int i=down,up=n*q/p; i<=up; i++){
    if(i == 0) continue;
    if(mx(i,n) > a) break;
    int M = q*i/euc(q,i);
    if(M/i<p*M/q) ans+=solve(p*M/q-M/i,M,a/i,n-1,i);
  }
  return ans;
}