N, M, P = map(int, input().split())
A = map(int, input().split())


def solve(a):
    x = 1
    ct = 0
    div = 1
    b = a
    while not b % P:
        div += 1
        b //= P

    if b == 1:
        return -1
    while x * a <= M:
        x *= b
        ct += div
    ct += 1
    return ct


ans = float('inf')
for a in A:
    s = solve(a)
    if s != -1:
        ans = min(ans, s)
print(ans if ans != float('inf') else -1)