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) if max(A)>M: print(1) exit() if L==1: print(-1) exit() now = 1 cnt = 0 while now <= M: cnt += 1 now *= L print(cnt)