import sys input = sys.stdin.readline N, M, P = map(int, input().split()) a = list(map(int, input().split())) a.sort() x = 1 res = 1000 for i in range(N): y = a[i] c = 0 while y % P == 0: y //= P c += 1 if y == 1: continue t = 1 for j in range(31): if t * a[-1] > M: res = min(res, (c + 1) * j + 1) break t *= y for i in range(100): if x > M: print(min(res, i)) break for j in range(N - 1, -1, -1): if (x * a[j]) % P or (x * a[j]) > M: x *= a[j] break else: if res != 1000: print(res) else: print(-1)