n, m, p = map(int, input().split()) A = list(map(int, input().split())) if m == 1: print(0) exit() if max(A) > m: print(1) exit() B = [] for a in A: while a%p == 0: a //= p B.append(a) B.sort(reverse=True) if B[0] == 1: print(-1) exit() x = 1 ans =0 while x <= m: ans += 1 x *= B[0] print(ans)