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 math
import random 
from queue import Queue
import time 



def main(arr,k):

  f={} 
  if k==1:
    print(len(set(arr)))
    return
  for e in arr:
    if e not in f:
      f[e]=0 
    f[e]+=1 
  ans=0

  for e in f:
    if f[e]!=0:

      val1=0 if e*k not in f else f[e*k] 
      
      val2=0 
      if e//k==e/k and e//k in f:
        val2=f[e//k]
       
      if val1+val2>f[e]:
        f[e]=0 
      else:
        if val1:
          f[e*k]=0 
        if val2:
          f[e//k]=0
 
  print(sum(f.values()))
  return 
n,k=list(map(int,input().split()))
arr=list(map(int,input().split()))
main(arr,k)
  

    