import java.io.PrintWriter import java.util.* import kotlin.math.* fun PrintWriter.solve() { val n = nextInt() val m = nextLong() val p = nextLong() val a = Array(n) { nextLong() } val b = a.copyOf() val c = Array(n) { 0 } for (i in 0 until n) { while (b[i] % p == 0L) { b[i] /= p c[i]++ } } val max_a = a.max()!! val max_b = b.max()!! val cnt = (0 until n).filter { b[it] == max_b }.map { c[it] }.min()!! if (max_b == 1L && max_a < m) { println(-1) return } var now = 1L var ans = 0 while (now <= m) { if (now * max_a > m) { ans++ break } else { now *= max_b ans += cnt + 1 } } println(ans) } fun main() { val writer = PrintWriter(System.out, false) writer.solve() writer.flush() } // region Scanner private var st = StringTokenizer("") private val br = System.`in`.bufferedReader() fun next(): String { while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine()) return st.nextToken() } fun nextInt() = next().toInt() fun nextLong() = next().toLong() fun nextLine() = br.readLine()!! fun nextDouble() = next().toDouble() // endregion