A *k*-multiple free set is a set of integers where there is no pair of integers where one is equal to another integer multiplied by *k*. That is, there are no two integers *x* and *y* (*x* &lt; *y*) from the set, such that *y* = *x*·*k*.

You're given a set of *n* distinct positive integers. Your task is to find the size of it's largest *k*-multiple free subset.
The first line of the input contains two integers *n* and *k* (1 ≤ *n* ≤ 10<sup class="upper-index">5</sup>, 1 ≤ *k* ≤ 10<sup class="upper-index">9</sup>). The next line contains a list of *n* distinct positive integers *a*<sub class="lower-index">1</sub>, *a*<sub class="lower-index">2</sub>, ..., *a*<sub class="lower-index">*n*</sub> (1 ≤ *a*<sub class="lower-index">*i*</sub> ≤ 10<sup class="upper-index">9</sup>).

All the numbers in the lines are separated by single spaces.
n, k = map(int, input().split())
arr = list(map(int, input().split()))

biggest = 0

sorted_arr = []
for i in range(len(arr)):
    sorted_arr.append((i, arr[i]))
    if (arr[i] > biggest):
        biggest = arr[i]

sorted_arr = sorted(sorted_arr, key = lambda item: item[1])

def bi_search(item, arr):
    l = 0
    r = len(arr)-1
    if (l == r):
        return -1

    def binary_search(arr, l, r, item):
        if (r >= l):
            mid = l+(r-l)//2
            if arr[mid][1] == item:
                return arr[mid][0]
            elif arr[mid][1] > item:
                return binary_search(arr, l, mid-1, item)
            else:
                return binary_search(arr, mid+1, r, item)
        else:
            return -1

    return binary_search(arr, l, r, item)

appeared = [-1]*(len(arr))
for i in range(len(arr)):
    if (arr[i] % k == 0):
        #print(f"arr[{i}] = {arr[i]} and k = {k}")
        before = arr[i]/k
        before_index = bi_search(before, sorted_arr)
        if (before_index != -1 and before_index < i):
            appeared[i] = before_index

result = 0
tmp = 0
last = 0
for i in range(len(appeared)):
    if (appeared[i] == -1):
        tmp += 1
    else:
        if (last > appeared[i]):
            tmp = i - last+1
        else:
            tmp = i-appeared[i]
        last = i

    if (tmp > result):
        result = tmp

print(result)
