import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop;

bool solve() {
    auto s = readln.split.map!(to!int);
    auto P = s[0];
    auto Q = s[1];
    auto A = s[2];
    auto N = s[3];
    if (P == 0) return false;

    long dfs(long p, long q, int n, long prod, long prev) {
        if (p == 0) return 1;
        if (prod * prev > A) return 0;
        if (n == N) return 0;
        if (p * prev > q * (N - n)) return 0;
        long ret = 0;
        for (long i = prev; prod * i <= A; ++i) {
            long x = i * p - q;
            long y = i * q;
            if (x < 0) continue;
            if (x != 0 && prod * i * i > A) continue;
            long g = gcd(x, y);
            ret += dfs(x / g, y / g, n + 1, prod * i, i);
        }
        return ret;
    }

    dfs(P, Q, 0, 1, 1).writeln;
    return true;
}

void main() {
    while (solve) {}
}

