#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <numeric>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <functional>
#include <complex>
#include <stack>

using namespace std;

const int INF = (1<<30) - 1;


int p,q,a,n,ans;

void dfs(int bunbo,int bunsi,int k,int now)
{
    if(bunbo*p==bunsi*q){
        ans++;
        return;
    }
    if(k==n)return;
    if(p*bunbo<q*bunsi)return;
    //now??\????????????????????????????¶????
    for(int i=now;i*bunbo<=a;i++){
        dfs(i*bunbo,bunsi*i+bunbo,k+1,i);
    }
}

int main(int argc, char const *argv[])
{
    while(1){
        cin>>p>>q>>a>>n;
        if(!p && !q)break;
        ans=0;
        
        dfs(1,0,0,1);
        
        cout<<ans<<endl;
    }
    return 0;
}