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 t in [0, 1]: print(-1) exit() x = 1 result = 1 while x * max_A <= M: x *= t result += 1 print(result)