import sys input = sys.stdin.readline N,M,P=map(int,input().split()) A=list(map(int,input().split())) B=[0]*N C=[0]*N for i in range(N): a=A[i] while a%P==0: B[i]+=1 a//=P C[i]=a K=[0]*50 for i in range(N): K[B[i]]=max(K[B[i]],C[i]) DP=[0]*100000 DP[0]=1 for i in range(95000): for j in range(49,-1,-1): DP[i+j+1]=max(DP[i+j+1],DP[i]*K[j]) for i in range(100000): if DP[i]>M: print(i) break else: print(-1)