#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),maxx(61,-1); ll mx = 0; rep(i,n){ cin >> a[i]; chmax(mx,a[i]); ll b = a[i]; ll c = 1; while(b%p==0){ b /= p; ++c; } chmax(maxx[c],b); } vector dp(4000,0); dp[0] = 1; for(int i=0;i<4000;i++){ for(int j=1;j<61;j++){ if(maxx[j]==-1) continue; if(i+j>=4000) break; chmax(dp[i+j],dp[i]*maxx[j]); } if(mx*dp[i] > m){ cout << i+1 << endl; return 0; } } cout << -1 << endl; return 0; }