#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, co1; for (int i = 0; i < n; i++) { cin >> a[i]; int co2 = 1; while (a[i] % p == 0) { a[i] /= p; co2++; } if (ans < a[i]) { ans = a[i]; co1 = co2; } } if (ans == 1) { cout << "-1" << endl; } else { int co = 0; while (m >= 1) { m /= ans; co++; } cout << co * co1 << endl; } }