#include // #include using namespace std; // using namespace atcoder; using ll = long long; using ull = unsigned long long; using P = pair; #define rep(i,n) for(ll i = 0;i < (ll)n;i++) #define ALL(x) (x).begin(),(x).end() #define MOD 1000000007 int main(){ ll n,m,p; cin >> n >> m >> p; ll k = 0; ll mx = 0; rep(i,n){ ll x;cin >> x; mx = max(mx,x); while(x%p == 0)x /= p; k = max(k,x); } if(mx > m)cout << 1 << "\n"; else if(k == 1)cout << -1 << "\n"; else { int res = 1; ll g = mx; while(g <= m)g *= k,res++; cout << res << "\n"; } return 0; }