mod = 1000000007 eps = 10**-9 inf = 10**17 def main(): import sys input = sys.stdin.readline N, M, P = map(int, input().split()) A = list(map(int, input().split())) if max(A) > M: print(1) exit() B = [1] * 40 for a in A: cnt = 0 aa = a while aa % P == 0: cnt += 1 aa //= P B[cnt] = max(B[cnt], aa) dp = [[-inf] * 40 for _ in range(40)] dp[0][0] = 1 ans = inf ma = max(A) for i in range(40): for j in range(40): if i != 0: dp[i][j] = dp[i-1][j] if j - i - 1 >= 0: dp[i][j] = max(dp[i][j], dp[i][j-i-1] * B[i]) if dp[i][j] * ma > M: ans = min(ans, j+1) if ans != inf: print(ans) else: print(-1) if __name__ == '__main__': main()