def dfs(p,q,a,n,num,den,k,cur)
    return 1 if p * den == q * num
    return 0 if k == n
    return 0 if p * den < q * num
    i = cur
    ret = 0
    while i * den <= a
        ret += dfs(p,q,a,n,num*i+den,i*den,k+1,i)
        i += 1
    end
    return ret
end
loop do
    p, q, a, n = gets.split.map(&:to_i)
    break if p==0&&q==0&&a==0&&n==0
    puts dfs(p,q,a,n,0,1,0,1)
end