## https://yukicoder.me/problems/no/1443 import heapq def main(): N, M, P = map(int, input().split()) A = list(map(int, input().split())) max_a = max(A) answer = float("inf") for a in A: a1 = a x = 0 while a1 % P == 0: x += 1 a1 //= P if a <= M and a1 == 1: continue y = 1 cost = 0 while y * max_a <= M and y * a <= M: y *= a1 cost += 1 + x answer = min(answer, cost + 1) if answer == float("inf"): print(-1) else: print(answer) if __name__ == "__main__": main()