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 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()
    for val in values:
        if val * k not in result and val / k not in result:
            result.add(val)
    print(len(result))

if __name__ == '__main__':
    main()
