## https://yukicoder.me/problems/no/1443 import heapq def main(): N, M, P = map(int, input().split()) A = list(map(int, input().split())) candidates = [] for a in A: a1 = a x = 0 while a1 % P == 0: x += 1 a1 //= P candidates.append((a, a1, 1 + x)) seen = {1: 0} fix = {} queue = [] heapq.heappush(queue, (0, 1)) answer = float("inf") while len(queue) > 0: cost, v = heapq.heappop(queue) if v in fix: continue fix[v] = cost for a, b, x in candidates: if v * a > M: answer = min(answer, cost + 1) continue w = v * b if w in fix: continue new_cost = cost + x if w not in seen or seen[w] > new_cost: seen[w] = new_cost heapq.heappush(queue, (new_cost, w)) if answer == float("inf"): print(-1) else: print(answer) if __name__ == "__main__": main()