#include #define rep(i, a, b) for(int i = (a); i <= (b); i ++) using std::cin, std::cout, std::cerr; using ll = long long; void Solve() { int n, m, p; cin >> n >> m >> p; std::vector a(n); rep(i, 0, n - 1) cin >> a[i]; const int k = 1000, t = 30 + 1; std::vector f(k + 1, 1); std::vector b(t + 1, 1); for(int x : a) { int c = 0; while(x % p == 0) { x /= p; c ++; } b[c + 1] = std::max(b[c + 1], x); } rep(i, 0, k) rep(j, 0, t) { if(i + j <= k) { f[i + j] = std::max(f[i + j], f[i] * b[j]); f[i + j] = std::min(f[i + j], ll(1e9)); } } bool ok = false; int ans = 1e9; int max = *std::max_element(a.begin(), a.end()); rep(i, 0, k) if(f[i] * max > m) { ok = true; ans = std::min(ans, i + 1); } cout << (ok ? ans : -1) << '\n'; } int main() { std::ios::sync_with_stdio(false); int T = 1; while(T --) { Solve(); } }