#include #define rep(i,n) for(int i=0;i<(int)(n);i++) #define chmin(x,y) x = min((x),(y)); #define chmax(x,y) x = max((x),(y)); using namespace std; using ll = long long ; using P = pair ; using pll = pair; const int INF = 1e9; const long long LINF = 1e17; const int MOD = 1000000007; //const int MOD = 998244353; const double PI = 3.14159265358979323846; int main(){ ll n,m,p; cin >> n >> m >> p; vector a(n); vector cnt(n,1); ll mx = 0; int mx_idx = -1; bool ok = false; rep(i,n){ cin >> a[i]; if(mx < a[i]){ mx = a[i]; mx_idx = i; } while(a[i]%p==0){ a[i] /= p; ++cnt[i]; } if(a[i]!=1) ok = true; } if(!ok && mx < m){ cout << -1 << endl; return 0; } double mxx = 0; int idx = -1; rep(i,n){ if(mxx*cnt[i] < a[i]){ mxx = a[i]/(double)cnt[i]; idx = i; } } ll ans = 0; ll x = 1; //cout << idx << endl; //cout << cnt[idx] << endl; while(x < m){ x *= a[idx]; ans += cnt[idx]; } ans -= cnt[idx]-1; ll res = 1; x = mx; while(x < m){ x *= a[idx]; res += cnt[idx]; } ans = min(ans,res); cout << ans << endl; return 0; }