""" dp[i] = i回の操作で行ける最大値 """ from sys import stdin import sys N,M,P = map(int,stdin.readline().split()) A = list(map(int,stdin.readline().split())) B = [] cnt = [0] * N for i in range(N): na = A[i] while na % P == 0: na //= P cnt[i] += 1 B.append(na) if max(B) == 1 and max(A) <= M: print (-1) sys.exit() dp = [1] * 1001 for i in range(1000): nmax = dp[i] if nmax > M: print (i) break for j in range(N): if nmax * A[j] > M: print (i+1) sys.exit() else: dp[i+1+cnt[j]] = max(dp[i+1+cnt[j]] , dp[i]*B[j])