#include using namespace std; #define ALL(x) begin(x),end(x) #define rep(i,n) for(int i=0;i<(n);i++) #define debug(v) cout<<#v<<":";for(auto x:v){cout<bool chmax(T &a,const T &b){if(abool chmin(T &a,const T &b){if(b ostream &operator<<(ostream &os,const vector&v){ for(int i=0;i<(int)v.size();i++) os< istream &operator>>(istream &is,vector&v){ for(T &x:v)is>>x; return is; } signed main(){ int n;ll m,p;cin>>n>>m>>p; vector v(60,-1); rep(i,n){ ll x;cin>>x; ll t=0; while(x%p==0) x/=p,t++; if(x>1) chmax(v[t],x); } map dp; dp[1]=0; rep(i,60)if(v[i]>0){ for(auto s:dp){ if(s.first<=m){ if(!dp.count(s.first*v[i])) dp[s.first*v[i]]=s.second+i+1; else chmin(dp[s.first*v[i]],s.second+i+1); } } } ll res=LINF; for(auto s:dp){ if(s.first>m) chmin(res,s.second); } if(res==LINF) cout<<-1<