# Header {{{
def assert(p)
  raise 'Assertion Failed' unless p
end

# Constants {{{
INF = 10**9
# }}}

# IO {{{
class MyIO
  def initialize
    @input = $stdin
    @output = $stdout
  end

  # @param filename [String]
  def set_input(filename)
    @input = File.open(filename, 'r')
  end

  def set_output(filename)
    @output = File.open(filename, 'w')
  end

  def int
    gets.to_i
  end

  def ints
    split.map(&:to_i)
  end

  def split
    @input.gets.chomp.split(' ')
  end
  alias_method :strings, :split

  def gets
    @input.gets.chomp
  end
  alias_method :string, :gets

  def puts(*args)
    @output.puts(*args)
  end
end

io = MyIO.new
# }}}

# Data Structures {{{

class Heap
  def initialize(&comparator)
    @arr = []
    @comparator = comparator || lambda { |lhs, rhs| lhs < rhs }
  end

  def push(v)
    @arr << v
    last_i = @arr.size - 1
    @arr[0], @arr[last_i] = @arr[last_i], @arr[0]
    make_heap!
  end
  alias_method :<<, :push

  def pop
    if @arr.size == 1
      @arr.pop
    else
      ret = @arr.first
      @arr[0] = @arr.pop
      make_heap!
      ret
    end
  end

  def top
    @arr.first
  end

  def empty?
    @arr.empty?
  end

  private

  def make_heap!
    make_heap_at!(0)
  end

  def make_heap_at!(i)
    return unless @arr[i]
    l, r = left(i), right(i)
    if @arr[l] && !@comparator.call(@arr[i], @arr[l])
      @arr[i], @arr[l] = @arr[l], @arr[i]
      make_heap_at!(l)
    elsif @arr[r] && !@comparator.call(@arr[i], @arr[r])
      @arr[i], @arr[r] = @arr[r], @arr[i]
      make_heap_at!(r)
    end
  end

  def parent(i)
    (i - 1) / 2
  end

  def left(i)
    i * 2 + 1
  end

  def right(i)
    i * 2 + 2
  end
end

# }}}

# Algorithms {{{

def lower_bound(arr, val)
  assert(arr.is_a?(Array))
  low, high = 0, arr.size
  while high - low > 1
    mid = (low + high) / 2
    if arr[mid] < val
      low = mid
    else
      high = mid
    end
  end
  if arr[low] >= val
    low
  else
    high
  end
end

def upper_bound(arr, val)
  assert(arr.is_a?(Array))
  low, high = 0, arr.size
  while high - low > 1
    mid = (low + high) / 2
    if arr[mid] <= val
      low = mid
    else
      high = mid
    end
  end
  if arr[low] > val
    low
  else
    high
  end
end

# }}}

# }}}

class Fraction
  attr_accessor :numerator, :denominator

  def self.tsuu(rhs, lhs)
    lcm = rhs.denominator.lcm(lhs.denominator)
    a = Fraction.new(rhs.numerator * lcm / rhs.denominator, lcm)
    b = Fraction.new(lhs.numerator * lcm / lhs.denominator, lcm)
    [a, b]
  end

  def initialize(numer, denom)
    @numerator = numer
    @denominator = denom
  end

  def -(rhs)
    lhs, rhs = Fraction.tsuu(self, rhs)
    Fraction.new(lhs.numerator - rhs.numerator, lhs.denominator).yaku!
  end

  def yaku
    gcd = @numerator.gcd(@denominator)
    Fraction.new(@numerator / gcd, @denominator / gcd)
  end

  def yaku!
    t = self.yaku
    self.numerator = t.numerator
    self.denominator = t.denominator
    self
  end

  def ==(other)
    a, b = Fraction.tsuu(self, other)
    a.numerator == b.numerator && a.denominator == b.denominator
  end

  def <(other)
    other = Fraction.new(other, 1) if other.is_a?(Integer)
    a, b = Fraction.tsuu(self, other)
    a.numerator < b.numerator
  end

  def to_s
    "#{@numerator} / #{@denominator}"
  end
end

io.set_input('inputs/0')

@a = nil
def solve(frac, start, ca, cn, fracs)
  return 0 if ca > @a
  if frac == 0
    # puts fracs.map(&:to_s).join(' + ')
    # puts "a = #{fracs.map(&:denominator).reduce(:*)}"
    return 1
  end
  return 0 if cn <= 0
  return 0 if start > ca
  ret = 0
  (start..(@a / ca)).each do |denom|
    unit = Fraction.new(1, denom)
    remain = frac - unit
    next if remain < 0
    nfracs = fracs + [unit]
    ret += solve(remain, denom, ca * denom, cn - 1, nfracs)
  end
  ret
end

while true
  p, q, a, n = io.ints
  @a = a
  break if p == 0
  puts solve(Fraction.new(p, q), 1, 1, n, [])
end

# vim: foldmethod=marker