#include using namespace std; using ll = long long; using pii = pair; #define REP(i, x) for(int i = 0; i < (x); i++) template inline bool chmax(T &a, T b) { if(a < b) { a = b; return true; } return false; } int main() { int n, m, p; scanf("%d %d %d", &n, &m, &p); vector a(n, 0), b(50, 0); REP(i, n) { scanf("%d", &a[i]); } int maxa = *max_element(a.begin(), a.end()); REP(i, n) { int cnt = 1, copy = a[i]; while(copy % p == 0) copy /= p, cnt++; chmax(b[cnt], a[i]); } vector achive(3100, 1ll); REP(i, 3000) { REP(j, 50) { if(achive[i] <= m) chmax(achive[i + j], achive[i] * b[j]); } } REP(i, 3100) { if(achive[i] * maxa > m) { printf("%d\n", i); return 0; } } puts("-1"); }