#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; long long a[200020]; int main() { long long n, m, p; cin >> n >> m >> p; long long ans = 1, m1 = 0, co1, co2; for (int i = 0; i < n; i++) { cin >> a[i]; if (m1 < a[i]) { m1 = a[i]; } co1 = 1; while (a[i] % p == 0) { a[i] /= p; co1++; } if (ans < a[i]) { ans = a[i]; co2 = co1; } } m /= m1; if (m == 0) { cout << "1" << endl; } else if (ans == 1) { cout << "-1" << endl; } else { int co = 1; while (m >= 1) { m /= ans; co++; } cout << co * co2 << endl; } }