#include<stdio.h>

int func(int,int,int,int,int);
int p,q,a,n;
int main(void){
  
  while(scanf("%d %d %d %d",&p,&q,&a,&n),p,q,a,n){
    printf("%d\n",func(n,1,1,0,1));
  }
  
  return 0;
}

int func(int turn,int last,int product,int c,int d){

  if(p*d==c*q)return 1;  

  if(!turn)return 0;
  
  int i,count=0;
  for(i=last;product*i<=a;i++){

    if(c/d+1/i<=p/q)
      count+=func(turn-1,i,product*i,i*c+d,i*d);

  }  
  return count;
}