from collections import * from itertools import * from functools import * from heapq import * import sys,math input = sys.stdin.readline N,M,P = map(int,input().split()) A = list(map(int,input().split())) C = defaultdict(int) for a in A: cnt = 0 while a%P==0: a //= P cnt += 1 C[cnt+1] = max(C[cnt+1],a) S = max(A) if S>M: print(1) exit() dp = [-1]*(1001) dp[0] = 1 f = lambda x:min(x,1000) for k,v in C.items(): for i in range(1000): if dp[i]==-1: continue dp[f(i+k)] = max(dp[f(i+k)],dp[i]*v) for i in range(1000): if dp[i]*S>M: print(i+1) exit() print(-1)