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) S=max(B) if S==1: print(-1) exit(0) t=1 K=0 while t<=M: t*=S K+=1 print(K)