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.

import sys



#
# def outer(total, values):
#     memo = [[-1 for _ in range(total + 1)] for _ in range(len(values))]
#     def dp(p1, i):
#
#         if i == len(values):
#             p2 = total - p1
#             return abs(p2 - p1)
#
#         if memo[i][p1] != -1:
#             return memo[i][p1]
#
#         curr_value = values[i]
#         val_2 = dp(p1, i + 1)
#         if val_2 == 0:
#             memo[i][p1] = 0
#             return 0
#         # Add it to player 1
#         val_1 = dp(p1 + curr_value, i + 1)
#         memo[i][p1] = min(val_1, val_2)
#         return  memo[i][p1]
#     return dp(0, 0)
#
#


def main():
    read = sys.stdin.readline
    n, k = (int(i) for i in read().split())
    values: list[int] = [int(i) for i in read().split()]
    result = set()
    # We need to take a greedy approach. We sort the values
    # and process them 1 by 1. We add them to the result only if it sat the constrain
    # The reasoning why we need to sort is that if we pick a middle element, say x
    # and x * k and x // k are in the list. We will only be able to add x. But instead
    # if we sort, we will process first x//k, ignore x, and add x *k, so we end up with 2 values.
    # Ex: 26 52 13. If you do not sort, you only add 26, If you sort, you end up with 13 and 52
    values.sort()
    # Traverse through the whole array
    for i in range(n):
        # Check if x/k is already present or not
        if values[i] % k == 0 and values[i] // k not in result:
            result.add(values[i])
        elif values[i] % k != 0:
            result.add(values[i])
    print(len(result))

if __name__ == '__main__':
    main()