#include "bits/stdc++.h" using namespace std; using ll = long long; using P = pair; const ll INF = (1LL << 61); ll mod = (ll)1e9 + 7; signed main() { ll N, M, P; cin >> N >> M >> P; vectorA(N); for (int i = 0; i < N; i++)cin >> A[i]; vectorB = A; ll ans = INF; bool ok = true; for (int i = 0; i < N; i++) { while (A[i] % P == 0) { A[i] /= P; } } sort(A.rbegin(), A.rend()); sort(B.rbegin(), B.rend()); for (int i = 0; i < N; i++) { if (B[i] > M) { ans = min(ans, 1LL); } if (A[i] % P != 0) { ll x = 1; ll now = 0; while (true) { if (x > M)break; now++; if (now > 100) { now = INF; break; } if(now != 1)x *= A[i]; else x *= B[0]; } ans = min(ans, now); } } //cout << ans << endl; cout << -1 << endl; }