#include <stdio.h>

int dfs(int p, int q, int a, int n, int pi, int prev){
  if(p == 0 && pi <= a){
    return 1;
  }else if(n == 0){
    return 0;
  }
  
  int sum = 0;
  int div = a / pi + 1;
  while(p * div >= q){
    if(n * q < p * div){
      div--;
      continue;
    }else if(div < prev){
      break;
    }
    
    sum += dfs(p * div - q, q * div, a, n - 1, pi * div, div);
    div--;
  }
  
  return sum;
}

int main(int argc,char* argv[]){
  for(;;){
    int p, q, a, n;
    scanf("%d %d %d %d", &p, &q, &a, &n);
    
    if(p == 0 && q == 0 && a == 0 && n == 0){
      break;
    }

    printf("%d\n", dfs(p, q, a, n, 1, 0));
  }

  return 0;  
}