import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines def main(N, M, p, A): # A = B * P^K B = [0] * N K = [0] * N for i, x in enumerate(A): e = 0 while x % p == 0: e += 1 x //= p B[i], K[i] = x, e # というか、K ごとの max_A AA = [0] * 30 BB = [0] * 30 for a, b, k in zip(A, B, K): if AA[k] < a: AA[k] = a BB[k] = b A, B = AA, BB # 総コストごとに、ベストな x MAX = 500 D = [1] * (MAX * 2) for i in range(MAX): x = D[i] for k in range(30): a, b = A[k], B[k] if a == 0: continue if x * a > M: return i + 1 to = x * b D[i + k + 1] = max(D[i + k + 1], to) return -1 N, M, P = map(int, readline().split()) A = list(map(int, readline().split())) print(main(N, M, P, A))