/*
 * Copyright (c) 2004 Kamo Hiroyasu
 *
 * Permission to use, copy, modify, and distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

/*
 * Unit Fraction Partition
 *  Author: Kamo Hiroyasu <wd@ics.nara-wu.ac.jp>
 */

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

unsigned int	gcd(unsigned int, unsigned int);
unsigned int	count_ufp(unsigned int, unsigned int, unsigned int, unsigned int);

unsigned int
gcd(unsigned int m, unsigned int n)
{
	unsigned int	k;

	while (n != 0) {
		k = m % n;
		m = n;
		n = k;
	}
	return m;
}

static unsigned int
count6(unsigned int p, unsigned int q, unsigned int a, unsigned int n,
       unsigned int l, unsigned int x0)
{
	unsigned int	count = 0;
	unsigned int	g;
	unsigned int	x, x_min, x_max;

	g = gcd(p, q);
	p /= g;
	q /= g;
	if (p == 1 && q >= x0 && l * q <= a) {
		count ++;
	}
	x_min = q / p + 1;
	if (x_min < x0) {
		x_min = x0;
	}
	x_max = n * q / p;
	if (x_max > a / l) {
		x_max = a / l;
	}
	for (x = x_min; x <= x_max; x ++) {
		count += count6(p * x - q, q * x, a, n - 1, l * x, x);
	}
	return count;
}

unsigned int
count_ufp(unsigned int p, unsigned int q, unsigned int a, unsigned int n)
{
	return count6(p, q, a, n, 1, 1);
}

main(int argc, char *argv[])
{
	unsigned int	p, q;
	unsigned int	a;
	unsigned int	n;

	while (scanf("%u%u%u%u", &p, &q, &a, &n) == 4
	       && p > 0 && q > 0 && a > 0 && n > 0) {
		printf("%u\n", count_ufp(p, q, a, n));
	}
	return 0;
}
