#include <stdio.h>
#include "stdlib.h"

typedef struct _params params;
typedef uint Result;

struct _params {
    uint p,q,a,n;
}input;


// initialization
Result init(params* out){
    // p/q a n
    scanf("%u %u %u %u",&out->p,&out->q,&out->a,&out->n);

    if(out->n==0)
        return 0;

    return 1;
}





uint calc_all_sols(uint product,uint sum,uint start,uint recursion_level){
    uint ret=0;

    if(recursion_level>input.n)
        return 0;

    if (product*input.p==sum*input.q)
        return 1;

    if (product*input.p<sum*input.q)
        return 0;

    for(uint i=start;i*product<=input.a;i++)
        ret+=calc_all_sols(i*product,(sum*i)+product,i,recursion_level+1);

    return ret;
}


int main() {

    while(init(&input))
        printf("%u\n",calc_all_sols(1,0,0,0));

    return 0;
}
