import sys input = sys.stdin.readline N, M, P = map(int, input().split()) a = list(map(int, input().split())) a.sort() x = 1 for i in range(40): if x > M: print(i) break for j in range(N - 1, -1, -1): if (x * a[j]) % P: x *= a[j] break else: print(-1)