#include using namespace std; using ll = long long; using pint = pair; int f(int n, int p) { while(n % p == 0) n /= p; return n; } int main() { ll n, m, p; cin >> n >> m >> p; vector a(n); for(auto &i : a) cin >> i; vector b = a; for(auto &i : a)i = f(i, p); ll nax = *max_element(a.begin(), a.end()); ll nax2 = *max_element(b.begin(), b.end()); __int128_t ret = 1; int cnt = 0; while(true) { cnt++; if((__int128_t)ret * nax2 > m) { cout << cnt << endl; return 0; } ret *= nax; if(cnt >= 1000) { cout << -1 << endl; return 0; } } cout << cnt << endl; }