lib C fun strtoll(s : UInt8*, p : UInt8**, b : Int32) : Int64 end class String def to_i64 C.strtoll(self, nil, 10) end end n, m, k = read_line.split.map(&.to_i64) a = read_line.split.map(&.to_i64) b, cnt = a.map { |i| c = 1 while i % k == 0 i //= k c += 1 end [i, c] }.transpose if b.max == 1 puts -1 exit end goal = m // a.max + 1 dp = [0] * 64 dp[0] = 1 (0...64).each do |x| (0...n).each do |i| if dp[x] < goal && x + cnt[i] < 64 dp[x + cnt[i]] = {dp[x + cnt[i]], dp[x] * b[i]}.max end end end puts dp.index { |i| i >= goal }.not_nil! + 1