#include <bits/stdc++.h>
using namespace std;

__attribute__((constructor))
void fast_io() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

int main() {
    int n, m, p;
    cin >> n >> m >> p;
    vector<int> a(n);
    for (auto& ai : a) cin >> ai;

    int mx = *max_element(a.begin(), a.end());
    if (mx > m) {
        cout << 1 << '\n';
        return 0;
    }
    m = (m + mx - 1) / mx;

    vector<int> cnt(n);
    for (int i = 0; i < n; ++i) {
        while (a[i] % p == 0) {
            a[i] /= p;
            cnt[i]++;
        }
    }
    if (all_of(a.begin(), a.end(), [](int x) { return x == 1; })) {
        cout << -1 << '\n';
        return 0;
    }

    map<int, int> mp;
    for (int i = 0; i < n; ++i) {
        if (mp.count(cnt[i])) {
            mp[cnt[i]] = max(mp[cnt[i]], a[i]);
        } else {
            mp[cnt[i]] = a[i];
        }
    }

    vector<int> dp(10000, 1);
    for (int i = 0; i < 1000; ++i) {
        if (dp[i] >= m) {
            cout << i + 1 << '\n';
            return 0;
        }
        for (auto [cost, x] : mp) {
            dp[i + cost + 1] = max(dp[i + cost + 1], dp[i] * x);
        }
    }
}