#include <bits/stdc++.h>

int64_t calcGCD(int64_t a, int64_t b)
{
	while (a)
	{
		b %= a;
		std::swap(a, b);
	}
	return b;
}

int64_t calcLCM(const int64_t a, const int64_t b)
{
	// if (a * b == 0) return 0;
	return a / calcGCD(a, b) * b;
}

//////////
// 分数 //
//////////

// 非負の有理数を扱える
// gcdを求める際にstd::swapを使うため、constexprには出来ない
class Fraction {
private:
	using Integer = int64_t;
	Integer numerator_, denominator_;

	void reduce()
	{
		const Integer gcd{(Integer)calcGCD(numer, denom)};
		numerator_ /= gcd;
		denominator_ /= gcd;
	}

public:
	const Integer &numer, &denom;

	Fraction(const Integer& initial_numerator = 0, const Integer& initial_denominator = 1)
		: numerator_(initial_numerator), denominator_(initial_denominator),
		numer(numerator_), denom(denominator_)
		{
			reduce();
		}
	
	// 四則演算
	Fraction operator+(const Fraction& operand) const
	{
		Fraction ret{1, (Integer)calcLCM(this->denom, operand.denom)};
		ret.numerator_ = this->numer * (ret.denom / this->denom) + operand.numer * (ret.denom / operand.denom);
		ret.reduce();

		return ret;
	}
	Fraction operator-(const Fraction& operand) const
	{
		Fraction ret{1, (Integer)calcLCM(this->denom, operand.denom)};
		ret.numerator_ = this->numer * (ret.denom / this->denom) - operand.numer * (ret.denom / operand.denom);
		ret.reduce();

		return ret;
	}
	Fraction operator*(const Fraction& operand) const
	{
		return {this->numer * operand.numer, this->denom * operand.denom};
	}
	Fraction operator*(const Integer& operand) const
	{
		return {this->numer * operand, this->denom};
	}
	Fraction operator/(const Fraction& operand) const
	{
		return {this->numer * operand.denom, this->denom * operand.numer};
	}
	Fraction operator/(const Integer& operand) const
	{
		return {this->numer, this->denom * operand};
	}

	// 代入
	Fraction& operator=(const Fraction& operand)
	{
		this->numerator_ = operand.numer;
		this->denominator_ = operand.denom;
		return *this;
	}
	Fraction& operator+=(const Fraction& operand)
	{
		*this = *this + operand;
		return *this;
	}
	Fraction& operator-=(const Fraction& operand)
	{
		*this = *this - operand;
		return *this;
	}
	Fraction& operator*=(const Fraction& operand)
	{
		*this = *this * operand;
		return *this;
	}
	Fraction& operator/=(const Fraction& operand)
	{
		*this = *this / operand;
		return *this;
	}

	// 比較
	bool operator==(const Fraction& operand) const
	{
		return this->numer * operand.denom == operand.numer * this->denom;
	}
	bool operator<=(const Fraction& operand) const
	{
		return this->numer * operand.denom <= operand.numer * this->denom;
	}
	bool operator>=(const Fraction& operand) const
	{
		return this->numer * operand.denom >= operand.numer * this->denom;
	}
	bool operator!=(const Fraction& operand) const
	{
		return !(*this == operand);
	}
	bool operator<(const Fraction& operand) const
	{
		return !(*this >= operand);
	}
	bool operator>(const Fraction& operand) const
	{
		return !(*this <= operand);
	}

	// その他
	// 逆数
	Fraction inv() const { return Fraction{denom, numer}; }
	// 天井関数
	Integer ceil() const { return (numer + denom - 1) / denom; }
	// 床関数
	Integer floor() const { return numer / denom; }
	// 小数型への変換
	long double real() const { return (long double)numer / denom; }
};

class Solve {
private:

	int rc(const Fraction& frac, const int64_t product, const int rest, const int64_t& prev_denom)
	{
		if (frac == Fraction{0, 1}) return 1;
		if (rest == 0) return 0;
		int count{};
		for (int64_t denom{std::max(prev_denom, frac.inv().ceil())}; Fraction{1, denom} * rest >= frac && denom <= product; denom++)
			count += rc(frac - Fraction{1, denom}, product / denom, rest - 1, denom);
		return count;
	}

public:
	bool is_last_query{};

	Solve()
	{
		int64_t p, q, a;
		int n;
		scanf("%lld%lld%lld%d", &p, &q, &a, &n);
		if (p == 0)
		{
			is_last_query = true;
			return;
		}
		printf("%d\n", rc({p, q}, a, n, 1));
	}
};

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1131&lang=jp
int main()
{
	while (!Solve().is_last_query);

	return 0;
}


Measured memory_bytes: 3216