N,M,P = map(int,input().split()) A = list(map(int,input().split())) B = [] for a in A: cost = 1 while a%P==0: a //= P cost += 1 if a!=1: B.append((cost,a)) n = len(B) dp = [1 for i in range(701)] for i in range(n): cost,a = B[i] next = [dp[j] for j in range(701)] for j in range(701-cost): next[j+cost] = max(next[j+cost],min(M+1,dp[j]*a),min(M+1,next[j]*a)) dp = next K = max(A) for i in range(701): if dp[i]*K >= M+1: print(i) break else: print(-1)