#include // #include // using namespace std; // using namespace atcoder; #define int long long #define rep(i, n) for(int i = 0;i<(int)(n);i++) #define all(v) (v).begin(),(v).end() using ll = long long; using lint = long long; using P = std::pair; signed main(void) { int n,m,p; std::cin >> n >> m >> p; std::vector v(n); int max = 0; rep(i, n) { std::cin >> v[i]; max=std::max(max,v[i]); if(v[i]>m) return printf("1\n"),0; if(v[i]<=m&&v[i]%p==0) { while(v[i]%p==0) v[i]/=p; } } std::sort(v.rbegin(),v.rend()); int ans = 1; if(v.front()==1) ans=-1; else { int x = 1; while(x<=m/max) x*=v.front(),ans++; } std::cout << ans << std::endl; return 0; }