import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.HashSet; import java.util.Set; public class Main { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] sa = br.readLine().split(" "); int n = Integer.parseInt(sa[0]); int m = Integer.parseInt(sa[1]); int p = Integer.parseInt(sa[2]); sa = br.readLine().split(" "); int[] a = new int[n]; for (int i = 0; i < n; i++) { a[i] = Integer.parseInt(sa[i]); } br.close(); int ans = Integer.MAX_VALUE; label: for (int i = 0; i < n; i++) { long x = 1; Set set = new HashSet<>(); set.add(x); int cnt = 0; while (x <= m) { cnt++; x *= a[i]; if (x > m) { break; } if (!set.add(x)) { continue label; } while (x % p == 0) { cnt++; x /= p; } } ans = Math.min(ans, cnt); } if (ans == Integer.MAX_VALUE) { ans = -1; } System.out.println(ans); } }