/*
AizuOnline A131
Title Unit Fraction Partition 
*/
#include <stdio.h>
#include <float.h>
#include <math.h>

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

int f2(p,q,a,n,m)
{
        int i,s,l;
        int g;

        if((g=gcd(p,q))>1)
                return(f2(p/g,q/g,a,n,m));
#if DEBUG
        printf("%d %d %d %d %d:",p,q,a,n,m);
#endif

        //check just p/q==1/i
        
        s=0;
        for(i=m;i<=a;i++)
                if(p*i==q)
                {
#ifdef DEBUG
                        printf("*\n");
#endif
                        s=1;
                }
                else if(p*i > q)
                        break;
        if(n==1)
                return(s);


                l=(int)sqrt((double)a);
#if DEBUG
        printf("%d \n",l);
#endif
                for(i=m;i<=l;i++)
                        if(p*i - q > 0)
                                s += f2(p*i -q,q*i,a/i,n-1,i);
                return(s);

}


int f(p,q,a,n)
{
        return(f2(p,q,a,n,1));
}

//
main()
{
        int ret;
        while(EOF!=scanf("%d %d %d %d",&p,&q,&a,&n) && (p||q||a||n))
        {
                ret=f(p,q,a,n);
                printf("%d\n",ret);
        }
return(0);
}