n,m,p=map(int,input().split()) a=list(map(int,input().split())) if any([x>m for x in a]): print(1) exit() bd=m mxv=0 for x in a: bd=min(bd,(m+1+x-1)//x) while x%p==0:x//=p mxv=max(mxv,x) if mxv==1: print(-1) exit() now=1 ans=0 while now<=bd: now*=mxv ans+=1 if now>m: print(ans) else: print(ans+1)