n, m, p = map(int, input().split()) A = list(map(int, input().split())) ma_ = max(A) if ma_ > m: print(1) exit() for i in range(n): while A[i] % p == 0: A[i] //= p ma = max(A) if ma == 1: print(-1) else: cnt = 0 x = 1 while x * ma_ <= m: x *= ma cnt += 1 print(cnt + 1)