from collections import * from itertools import * from functools import * from heapq import * import sys,math input = sys.stdin.readline N,M,P = map(int,input().split()) A = list(map(int,input().split())) B = [] for a in A: while a%P==0: a //= P B.append(a) L = max(B) S = max(A) if S>M: print(1) exit() if L==1: print(-1) exit() now = S cnt = 1 while now <= M: cnt += 1 now *= L print(cnt)