#include<iostream>
#include<cstdio>

using namespace std;

typedef long long ll;

ll p,q,a,n,ans;
int vn;

void dfs(ll depth, ll nume, ll deno, ll product, ll vi){
    if(product > a || nume*q > p*deno) return;
    if(nume*q == p*deno){
        ans++;
        return;
    }
    if(depth == n) return;
    for(ll i=min(vi, a/product);i>=1;i--) dfs(depth+1, nume*i+deno, deno * i, product*i, i);
}

int main(){
    while(scanf("%lld%lld%lld%lld", &p, &q, &a, &n) && p){
        ans = 0LL;
        dfs(0LL, 0LL, 1LL, 1LL, a);
        printf("%lld\n", ans);
    }
}
