def f(x): while x % P == 0: x //= P return x N, M, P, *A = map(int, open(0).read().split()) max_A = max(A) t = max(map(f, A)) if max_A > M: print(1) exit() if t in [0, 1]: print(-1) exit() x = 1 result = 0 while True: result += 1 if x * max_A > M: break x *= t print(result)