from math import ceil N, M, P = map(int,input().split()) A = list(map(int, input().split())) M += 1 m = max(A) if m>M: print(1) exit() d = {} for i in range(N): cnt = 1 while A[i]%P==0: cnt += 1 A[i] //= P if A[i]==1: continue if cnt in d: d[cnt] = max(d[cnt],A[i]) else: d[cnt] = A[i] if len(d)==0: print(-1) exit() n = ceil(M/m) dp = [0]*901 dp[0] = 1 for i in range(901): for key in d.keys(): if i+key<=60: dp[i+key] = max(dp[i+key],dp[i]*d[key]) for i in range(901): if dp[i]>=n: print(i+1) exit()