n, m, p = map(int, input().split()) a = list(map(int, input().split())) mx = max(a) t = (m + mx - 1) // mx if t == 1: print(1) exit() q = [] for ai in a: cnt = 1 while ai % p == 0: cnt += 1 ai //= p if ai == 1: continue q.append((ai, cnt)) dp = [0] * 100 dp[0] = 1 for i in range(50): for x, c in q: dp[i + c] = max(dp[i + c], dp[i] + x) for i, v in enumerate(dp): if v >= t: print(i + 1) break else: print(-1)