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