#include "bits/stdc++.h" using namespace std; using ll = long long; using P = pair; const ll INF = (1LL << 61); ll mod = (ll)1e9 + 7; // i回操作をするときのxの値の最大値 ll dp[100010]; signed main() { ll N, M, P; cin >> N >> M >> P; vectorA(N); for (int i = 0; i < N; i++)cin >> A[i]; // 最後に掛けることができる ll t = 0; for (int i = 0; i < N; i++)t = max(t, A[i]); // 割る操作をi回するときの最大値 vectorm(62, 1); for (int i = 0; i < N; i++) { ll cnt = 0; while (A[i] % P == 0) { A[i] /= P; cnt++; } m[cnt] = max(m[cnt], A[i]); } dp[0] = 1; for (int i = 0; i < 10010; i++) { if (dp[i] * t > M) { cout << i + 1 << endl; return 0; } for (int j = 0; j <= 60; j++) { // 遷移 dp[i + j + 1] = max(dp[i + j + 1], dp[i] * m[j]); } } cout << -1 << endl; }