#include #define rep(i, a, n) for(int i = a; i < n; i++) using namespace std; using ll = long long; using P = pair; int main() { ll n, m, p; cin >> n >> m >> p; vector a(n); rep(i, 0, n) cin >> a[i]; sort(a.begin(), a.end()); int cnt = 0; ll mx = 0; int mx_index = -1; rep(i, 0, n){ if(mx < a[i]%p){ mx = a[i]%p; mx_index = i; } } if(a[n-1] > m){ cout << 0 << endl; return 0; } if(mx <= 0){ cout << -1 << endl; return 0; } ll x = 1; while(x <= m){ cnt++; if(x*a[n-1] > m) break; else if(x%p == 0) x /= p; else x *= a[mx_index]; } cout << cnt << endl; return 0; }