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 < 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.


-----Input-----

The first line of the input contains two integers n and k (1 ≤ n ≤ 10^5, 1 ≤ k ≤ 10^9). The next line contains a list of n distinct positive integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 10^9).

All the numbers in the lines are separated by single spaces.


-----Output-----

On the only line of the output print the size of the largest k-multiple free subset of {a_1, a_2, ..., a_{n}}.


-----Examples-----
Input
6 2
2 3 6 5 4 10

Output
3



-----Note-----

In the sample input one of the possible maximum 2-multiple free subsets is {4, 5, 6}.

Difficulty: MEDIUM

Solutions:
import sys
input = sys.stdin.buffer.readline
from collections import Counter

def solution():
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	l.sort()
	c = Counter(l)
	i = 0
	for i in l:
		x = i
		if c[i] != 1:
			continue
		if c[k * x] == 1 and k * x != x:
			c[k * x] -= 1
	print(sum(c.values()))
solution()


import sys

def main():
	(n, k) = map(int, sys.stdin.readline().strip().split())
	arr = list(map(int, sys.stdin.readline().strip().split()))
	arr.sort(reverse=True)
	dic = {}
	for a in arr:
		if a * k not in dic:
			dic[a] = 1
	print(len(dic))
main()


import sys
from math import *

def minp():
	return sys.stdin.readline().strip()

def mint():
	return int(minp())

def mints():
	return map(int, minp().split())
(n, k) = mints()
if k == 1:
	print(n)
	exit(0)
m = dict()
for i in mints():
	c = 0
	x = i
	while x % k == 0:
		x //= k
		c += 1
	if x not in m:
		m[x] = [0] * 34
	m[x][c] += 1
r = 0
for i in m:
	f = True
	for j in m[i]:
		if f and j != 0:
			r += 1
			f = False
		else:
			f = True
print(r)


import bisect
(n, k) = map(int, input().split())
a = list(sorted(map(int, input().split())))
cnt = 0
for i in range(len(a)):
	if not a[i]:
		continue
	cnt += 1
	x = a[i] * k
	pos = bisect.bisect_left(a, x)
	if pos < len(a) and a[pos] == x:
		a[pos] = 0
print(cnt)


import sys

def fastio():
	from io import StringIO
	from atexit import register
	global input
	sys.stdin = StringIO(sys.stdin.read())
	input = lambda : sys.stdin.readline().rstrip('\r\n')
	sys.stdout = StringIO()
	register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()

def debug(*var, sep=' ', end='\n'):
	print(*var, file=sys.stderr, end=end, sep=sep)
INF = 10 ** 20
MOD = 10 ** 9 + 7
I = lambda : list(map(int, input().split()))
from math import gcd
from math import ceil
from collections import defaultdict as dd, Counter
from bisect import bisect_left as bl, bisect_right as br
(n, k) = I()
a = I()
a.sort()
idx = dd(int)
ans = 0
for i in range(n):
	idx[a[i]] = i
for i in range(n):
	if not a[i]:
		continue
	cur = 0
	x = a[i]
	while x in idx:
		cur += 1
		a[idx[x]] = 0
		x *= k
		if k == 1:
			break
	ans += (cur + 1) // 2
print(ans)


(n, k) = map(int, input().split())
ai = list(map(int, input().split()))

def binsearch(num):
	high = n - 1
	low = 0
	mid = (high + low) // 2
	while high >= low:
		if ai[mid] < num:
			low = mid + 1
		elif ai[mid] > num:
			high = mid - 1
		else:
			return mid
		mid = (high + low) // 2
	return -1
ai.sort()
ar = [0] * n
ans = 0
for i in range(n):
	if ar[i]:
		continue
	num = binsearch(ai[i] * k)
	if num != -1:
		ar[num] = 1
		ans += 1
if k == 1:
	ans = 0
print(n - ans)


def bs(l=0, r=0, val=0):
	l1 = l
	r1 = r
	while l1 <= r1:
		mid = (l1 + r1) // 2
		if a[mid] < val:
			l1 = mid + 1
		elif a[mid] > val:
			r1 = mid - 1
		elif a[mid] == val:
			return mid
	return -1
mark = {}
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
sum = 0
for i in range(0, n):
	if mark.get(i, False) == False:
		temp = bs(i, n - 1, a[i] * k)
		mark[temp] = True
		sum += 1
print(sum)


import sys
read = lambda : sys.stdin.readline().strip()
readi = lambda : map(int, read().split())
from collections import *
(n, k) = readi()
nums = list(readi())
bin1 = bin2 = 0
counts = defaultdict(int)
for i in nums:
	counts[i] += 1
keys = sorted(list(counts.keys()))
for key in keys:
	if key in counts:
		if key * k in counts:
			bin2 += counts[key * k]
			counts.pop(k * key)
		bin1 += counts[key]
		counts.pop(key)
print(max(bin1, bin2))


from sys import stdin
__author__ = 'artyom'

def read_next_line():
	return list(map(int, stdin.readline().strip().split()))
(n, k) = read_next_line()
a = read_next_line()
res = set(a)
if k > 1:
	excl = set()
	for x in reversed(sorted(a)):
		if x % k > 0 or x in excl:
			continue
		p = x / k
		if p in res:
			res.remove(p)
			excl.add(p)
print(len(res))


def K_multiple(a, n, k):
	a.sort()
	s = set()
	for i in range(n):
		if a[i] % k == 0 and a[i] // k not in s or a[i] % k != 0:
			s.add(a[i])
	print(len(s))
(n, k) = input().split()
n = int(n)
k = int(k)
a = list(map(int, input().split()))
K_multiple(a, n, k)


from collections import defaultdict
(n, k) = [int(i) for i in input().strip().split()]
l = [int(i) for i in input().strip().split()]
if k == 1:
	print(n)
else:
	l.sort()
	ndict = defaultdict(list)
	for x in l:
		i = x
		while i % k == 0:
			i = i / k
		ndict[i].append(x)
	ans = 0
	for i in ndict.values():
		count = 0
		while count < len(i):
			if count == len(i) - 1:
				ans += 1
				break
			if i[count] * k != i[count + 1]:
				ans += 1
				count += 1
			else:
				ans += 1
				count += 2
	print(ans)


from collections import *
(n, k) = map(int, input().split())
(a, ans, mem) = (sorted(map(int, input().split())), 0, defaultdict(int))
for i in a:
	if i % k == 0 and (not mem[i // k]) or i % k:
		mem[i] = 1
		ans += 1
print(ans)


def answer(n, k, A):
	A.sort()
	d = {}
	count = 0
	for i in range(n):
		if A[i] not in d:
			count += 1
			d[A[i] * k] = 1
	return count
(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
print(answer(n, k, arr))


(n, k) = map(int, input().split(' '))
a = [int(i) for i in input().split(' ')][:n]
a.sort()
m = dict()
removed = dict()
for i in range(n):
	m[a[i]] = int(1)
count = int(n)
for i in range(n):
	if removed.get(a[i], 0) == 0:
		if m.get(a[i] * k, -1) == 1 and k != 1:
			removed[a[i] * k] = 1
			count -= 1
print(count)


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
d = {}
c = 1
p = [0] * n
d[l[0]] = 0
p[0] = 1
for i in range(1, n):
	a = c
	if l[i] % k == 0 and l[i] // k in d:
		a = d[l[i] // k]
		c -= 1
	d[l[i]] = a
	p[a] += 1
	c += 1
s = 0
for i in range(n):
	if p[i] == 0:
		break
	s += p[i] // 2
	if p[i] % 2 != 0:
		s += 1
print(s)


class K_Free:

	def __init__(self, n, k):
		self.n = n
		self.k = k
		self.fuad = list(map(int, input().split()))
		self.fuad.sort()
		self.ans = []

	def Solve(self):
		for x in self.fuad:
			if x % self.k:
				self.ans.append(x)
			elif int(x / self.k) not in self.ans:
				self.ans.append(x)
		return len(self.ans)
(a, b) = map(int, input().split())
obj = K_Free(a, b)
print(obj.Solve())


def solve():
	(n, k) = map(int, input().split())
	a = sorted([int(i) for i in input().split()])
	b = set(a)
	if k != 1:
		for i in a:
			if i in b:
				b.discard(i * k)
	print(len(b))
solve()


(n, k) = list(map(int, input().split()))
arr = list(map(int, input().split()))
lol = {}
flag = {}
arr.sort()
for x in arr:
	flag[x] = 1
ans = 0
for i in range(len(arr)):
	if arr[i] in lol:
		continue
	cur = arr[i]
	cnt = 0
	while cur <= 1000000000:
		lol[cur] = 1
		if cur in flag:
			cnt += 1
		else:
			break
		cur = cur * k
		if k == 1:
			break
	ans += (cnt + 1) // 2
print(ans)


(n, k) = map(int, input().split())
s = list(map(int, input().split()))
s = sorted(s)
my_dict = {}
for i in s:
	if i not in my_dict:
		my_dict[i] = 1
ans = {}
if k != 1:
	count = 0
	for i in my_dict:
		if i * k in my_dict and i not in ans:
			ans[i * k] = 1
print(len(my_dict) - len(ans))


(n, k) = list(map(int, input().split()))
L = list(map(int, input().split()))
L.sort(reverse=True)
S = {}
for i in range(n):
	if L[i] * k in S:
		continue
	S[L[i]] = 1
print(len(S))


k = int(input().split()[1])
l = sorted(map(int, input().split()))
res = set()
for i in l:
	if i % k != 0:
		res.add(i)
	elif i // k not in res:
		res.add(i)
print(len(res))


import sys, threading
sys.setrecursionlimit(10 ** 6)
scan = lambda : map(int, input().split())
(n, k) = scan()
arr = list(scan())
dic = {}
arr.sort()
for i in arr:
	if i % k == 0:
		if dic.get(i / k, 0):
			continue
	if dic.get(i, 0):
		dic[i] += 1
	else:
		dic[i] = 1
ans = 0
for i in dic:
	ans += dic[i]
print(ans)


r = input('').split(' ')
x = int(r[0])
y = int(r[1])
l = input('').split(' ')
l = [int(x) for x in l]
l.sort()
k = {}
r = len(l)
for g in range(len(l)):
	if l[g] % y == 0:
		rk = l[g] // y
		if rk not in k:
			k[l[g]] = 1
		else:
			r -= 1
	else:
		k[l[g]] = 1
print(r)


import io, os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()

def search(a, t):
	l = 0
	r = len(a) - 1
	while r - l >= 0:
		mid = (l + r) // 2
		if a[mid] == t:
			return mid
		if a[mid] < t:
			l = mid + 1
		if a[mid] > t:
			r = mid - 1
	return -1
if k == 1:
	print(n)
else:
	v = [0] * n
	ct = 0
	for i in range(n):
		if not v[i]:
			q = a[i]
			in_ct = 0
			while search(a, q) != -1:
				v[search(a, q)] = 1
				in_ct += 1
				q *= k
			ct += (in_ct + 1) // 2
	print(ct)


(n, k) = [int(x) for x in input().split()]
arr = [int(x) for x in input().split()]
arr.sort()
h = {}
count = 0
for i in range(n):
	h[arr[i]] = 1
for i in range(n):
	if h[arr[i]] != 0:
		if arr[i] * k in h:
			h[arr[i] * k] = 0
		count += 1
print(count)


(n, k) = map(int, input().split())
l = [int(x) for x in input().split()]
l.sort()
s = set([])
ans = 0
for i in l:
	if i % k == 0:
		if i // k not in s:
			s.add(i)
			ans += 1
	else:
		ans += 1
		s.add(i)
print(ans)


(n, k) = input().split()
n = int(n)
k = int(k)
a = [int(i) for i in input().split()]
a.sort()
mul = [0] * n

def search(a, val, k):
	l = 0
	r = len(a) - 1
	while l <= r:
		mid = (l + r) // 2
		if a[mid] == val * k:
			return mid
		elif a[mid] > val * k:
			r = mid - 1
		else:
			l = mid + 1
	return -1
if n == 1:
	print(1)
else:
	count = 0
	for i in range(n):
		pos = search(a, a[i], k)
		if pos != -1 and pos != i:
			mul[pos] = mul[i] + 1
	for i in range(n):
		if not mul[i] % 2:
			count += 1
	print(count)


from __future__ import print_function
from collections import Counter, OrderedDict
from itertools import permutations as perm
from fractions import Fraction
from collections import deque
from sys import stdin
from bisect import *
from heapq import *
import math
g = lambda : stdin.readline().strip()
gl = lambda : g().split()
gil = lambda : [int(var) for var in gl()]
gfl = lambda : [float(var) for var in gl()]
gcl = lambda : list(g())
gbs = lambda : [int(var) for var in g()]
mod = int(1000000000.0) + 7
inf = float('inf')
(n, k) = gil()
a = gil()
ans = 0
a.sort()
avail = set(a)
for v in a:
	if v not in avail:
		continue
	i = 1
	while v * k ** i in avail:
		avail.remove(v * k ** i)
		i += 1
	ans += math.ceil(i / 2)
print(ans)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=True)
l = {}
for i in range(n):
	if a[i] * k not in l:
		l[a[i]] = 1
print(len(l))


def search(v, l, n):
	low = 0
	hi = n - 1
	while low <= hi:
		mid = low + (hi - low) // 2
		if l[mid] > v:
			hi = mid - 1
		elif l[mid] < v:
			low = mid + 1
		else:
			return mid
	return -1
(n, k) = map(int, input().strip().split())
v = list(map(int, input().strip().split()))
kmult = [False] * n
if k == 1:
	print(n)
	quit()
c = n
v.sort()
hi = n
for j in range(n - 1, -1, -1):
	i = v[j]
	if not kmult[j] and i % k == 0:
		pos = search(i // k, v, hi)
		if pos >= 0:
			kmult[pos] = True
			c -= 1
			hi = pos
print(c)


s = input().split()
(n, k) = (int(s[0]), int(s[1]))
s = input().split()
(a, b) = ([], [])
for x in s:
	a.append(int(x))
	b.append(0)
a.sort()
ans = n
for i in range(n):
	if b[i] == -1:
		continue
	(l, r) = (i + 1, n - 1)
	j = -1
	while l < r and j == -1:
		m = (l + r) // 2
		if a[m] < a[i] * k:
			l = m + 1
		elif a[m] > a[i] * k:
			r = m
		else:
			j = m
	m = (l + r) // 2
	if a[m] == a[i] * k and a[i] < a[m]:
		j = m
	if j != -1:
		if b[j] != -1:
			b[j] = -1
			ans -= 1
print(ans)


from sys import stdin

def main():
	inp = stdin
	(n, k) = list(map(int, inp.readline().split()))
	nums = list(map(int, inp.readline().split()))
	nums.sort(reverse=True)
	final = set()
	for i in range(0, n):
		mult = nums[i] * k
		if not mult in final:
			final.add(nums[i])
	print(len(final))
main()


(n, k) = map(int, input().split())
t = list(map(int, input().split()))
if k == 1:
	print(len(set(t)))
else:
	p = [set() for i in range(30)]
	for i in t:
		j = 0
		while i % k == 0:
			i //= k
			j += 1
		p[j].add(i)
	for j in range(1, 30):
		p[j] -= p[j - 1]
	print(sum((len(i) for i in p)))


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
import copy
import time
starttime = time.time()
mod = int(pow(10, 9) + 7)
mod2 = 998244353

def data():
	return sys.stdin.readline().strip()

def out(*var, end='\n'):
	sys.stdout.write(' '.join(map(str, var)) + end)

def L():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
try:
	sys.stdin = open('input.txt', 'r')
except:
	pass

def pmat(A):
	for ele in A:
		print(*ele, end='\n')

def seive():
	prime = [1 for i in range(10 ** 6 + 1)]
	prime[0] = 0
	prime[1] = 0
	for i in range(10 ** 6 + 1):
		if prime[i]:
			for j in range(2 * i, 10 ** 6 + 1, i):
				prime[j] = 0
	return prime
(n, k) = L()
A = L()
if k == 1:
	print(len(set(A)))
	exit()
s1 = set()
s2 = set()
d = {}
for ele in A:
	s1.add(ele)
	d[ele] = d.get(ele, 0) + 1
for ele in sorted(list(s1)):
	if ele % k == 0 and ele // k in s2:
		continue
	s2.add(ele)
ans = 0
for ele in s2:
	ans += d[ele]
print(ans)
endtime = time.time()


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
ans = set()
a.sort()
for i in range(n):
	if a[i] / k not in ans:
		ans.add(a[i])
print(len(ans))


import sys
import math
MAXNUM = math.inf
MINNUM = -1 * math.inf

def getInts():
	return map(int, sys.stdin.readline().rstrip().split(' '))

def getString():
	return sys.stdin.readline().rstrip()

def solve(n, k, ints):
	cache = {}
	total = 0
	for ele in ints:
		length = 1
		if ele * k in cache:
			after = ele * k
			end = cache[after][1]
			total -= (cache[after][2] + 1) // 2
			length += cache[after][2]
		else:
			end = ele
		if ele % k == 0 and ele // k in cache:
			before = ele // k
			start = cache[before][0]
			total -= (cache[before][2] + 1) // 2
			length += cache[before][2]
		else:
			start = ele
		cache[start] = (start, end, length)
		cache[end] = (start, end, length)
		total += (length + 1) // 2
	return total

def printOutput(ans):
	sys.stdout.write(str(ans))

def readinput():
	(n, k) = getInts()
	ints = list(getInts())
	printOutput(solve(n, k, ints))
readinput()


from math import ceil
(n2, k) = map(int, input().split())
l = list(map(int, input().split()))
l = sorted(l)
d = {}
for i in l:
	d[i] = 1
if k == 1:
	print(len(d))
else:
	used = {}
	ans = 0
	for i in l:
		if i in used:
			continue
		n = i
		num = 0
		while n in d:
			if n in used:
				break
			used[n] = 1
			n *= k
			num += 1
		ans += num // 2
		if num & 1 > 0:
			ans += 1
	print(ans)


(n, m) = map(int, input().split())
arr = list(map(int, input().split()))
arr.sort()
s = set()
for i in range(n):
	if arr[i] % m != 0:
		s.add(arr[i])
	elif arr[i] // m not in s:
		s.add(arr[i])
print(len(s))


def bSearch(x, li):
	l = 0
	h = len(li)
	while l <= h:
		m = (l + h) // 2
		if li[m] == x:
			return m
		elif li[m] > x:
			h = m - 1
		else:
			l = m + 1
	return -1
(n, k) = map(int, input().split())
li = list(map(int, input().split()))
li.sort()
s = set()
for i in range(n):
	if li[i] % k == 0:
		z = bSearch(li[i] // k, li)
		if z != -1:
			if li[z] not in s:
				s.add(li[i])
		else:
			s.add(li[i])
	else:
		s.add(li[i])
print(len(s))


(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
arr.sort()
visited = [0] * n
i = 0
group_2 = []
group_1 = []
while i < n:
	if visited[i] == 0:
		group_1.append(arr[i])
		visited[i] = 1
		x = arr[i] * k
		left = i
		right = n - 1
		while left <= right:
			mid = left + (right - left) // 2
			if arr[mid] == x:
				visited[mid] = 1
				group_2.append(arr[mid])
				break
			elif arr[mid] < x:
				left = mid + 1
			else:
				right = mid - 1
		i += 1
	else:
		i += 1
print(max(len(group_1), len(group_2)))


(n, k) = map(int, input().split())
a = sorted([int(i) for i in input().split()])
b = set(a)
c = list(b)
if k != 1:
	for i in c:
		if i in b:
			b.discard(i * k)
print(len(b))


from collections import OrderedDict

def kmultiple(x, k):
	c = 0
	for e in x:
		if x[e] != 0:
			c += 1
			if e * k in x:
				x[e * k] = 0
	return c
x = OrderedDict()
(_, k) = input().split()
k = int(k)
lst = [int(x) for x in input().split()]
lst.sort()
for e in lst:
	x[e] = 1
print(kmultiple(x, k))


from sys import stdin, setrecursionlimit
import collections
(n, k) = list(map(int, stdin.readline().split()))
if k == 1:
	print(n)
	exit()
myset = list(map(int, stdin.readline().split()))
myset.sort()
myset = set(myset)
count = 0
can = dict()
for i in myset:
	can[i] = True
for i in myset:
	if i * k in myset and can[i] == True:
		count += 1
		can[i * k] = False
print(n - count)


(n, k) = map(int, input().split())
a = list(sorted(map(int, input().split()), reverse=True))
s = set()
for i in range(len(a)):
	if a[i] * k not in s:
		s.add(a[i])
print(len(s))


n = input()
n = n.split(' ')
(a, b) = (int(n[0]), int(n[1]))
A = []
S = []
k = b
o = input()
o = o.split(' ')
for i in range(a):
	A.append(int(o[i]))
A = sorted(A)
for i in A:
	if i % k != 0:
		S.append(i)
	elif i // k not in S:
		S.append(i)
l = len(S)
print(l)


import sys
k = int(sys.stdin.readline().split()[1])
t = list(map(lambda s: int(s), sys.stdin.readline().split()))
t.sort()

def find(x, a, b):
	while True:
		if a == b:
			if x == t[a]:
				return a
			else:
				return None
		m = a + (b - a) // 2
		if x > t[m]:
			a = m + 1
		else:
			b = m
u = [True for i in t]
s = 0
for i in range(len(t)):
	if u[i]:
		s += 1
		u[i] = False
		j = find(t[i] * k, 0, len(t) - 1)
		if j is not None:
			u[j] = False
print(s)


readints = lambda : map(int, input().strip('\n').split())
(n, k) = readints()
a = list(readints())
a.sort()
ans = set()
for x in a:
	if x % k != 0 or x / k not in ans:
		ans.add(x)
print(len(ans))


from sys import stdin, stdout

def INI():
	return int(stdin.readline())

def INL():
	return [int(_) for _ in stdin.readline().split()]

def INS():
	return stdin.readline()

def MOD():
	return pow(10, 9) + 7

def OPS(ans):
	stdout.write(str(ans) + '\n')

def OPL(ans):
	[stdout.write(str(_) + ' ') for _ in ans]
	stdout.write('\n')
from bisect import bisect_left
(n, k) = INL()
X = sorted(INL())
BOOL = [True for _ in range(n)]
for _ in range(n):
	if BOOL[_] == True and k * X[_] <= X[-1] and (k != 1):
		i = bisect_left(X, k * X[_])
		if X[i] == k * X[_]:
			BOOL[i] = False
OPS(BOOL.count(True))


(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
arr = sorted(arr)
ans = set()
for i in range(n):
	if arr[i] % k != 0:
		ans.add(arr[i])
	elif arr[i] % k == 0 and arr[i] // k not in ans:
		ans.add(arr[i])
print(len(ans))


(n, m) = list(map(int, input().split()))
l = list(map(int, input().split()))
l = sorted(l)
ma = 1
d = {l[0]}
for i in range(1, n):
	if l[i] / m not in d:
		d.add(l[i])
		ma += 1
print(ma)


(n, k) = list(map(int, input().split(' ')))
a = list(map(int, input().split(' ')))
a.sort()
s = []
d = {}
m = 0
for i in a:
	if i % k != 0:
		s.append(i)
		d[i] = 1
		m += 1
	elif i // k not in d:
		s.append(i)
		d[i] = 1
		m += 1
print(m)


import sys
import string
import math
import heapq
from collections import defaultdict
from collections import deque
from collections import Counter
from functools import lru_cache
from fractions import Fraction

def mi(s):
	return map(int, s.strip().split())

def lmi(s):
	return list(mi(s))

def tmi(s):
	return tuple(mi(s))

def mf(f, s):
	return map(f, s)

def lmf(f, s):
	return list(mf(f, s))

def js(lst):
	return ' '.join((str(d) for d in lst))

def jsns(lst):
	return ''.join((str(d) for d in lst))

def line():
	return sys.stdin.readline().strip()

def linesp():
	return line().split()

def iline():
	return int(line())

def mat(n):
	matr = []
	for _ in range(n):
		matr.append(linesp())
	return matr

def matns(n):
	mat = []
	for _ in range(n):
		mat.append([c for c in line()])
	return mat

def mati(n):
	mat = []
	for _ in range(n):
		mat.append(lmi(line()))
	return mat

def pmat(mat):
	for row in mat:
		print(js(row))

class DSU:

	def __init__(self, n, important=None):
		self.parents = {i: i for i in n}
		self.size = {i: 1 for i in n}
		self.num_components = len(n)
		self.important = important if important else set()
		self.num_edges = {i: 0 for i in n}

	def rank(self, x):
		if x in self.important:
			return float('inf')
		if x not in self.size:
			raise ValueError('{0} not in the set.'.format(x))
		return self.size[x]

	def union(self, x, y):
		if x not in self.parents or y not in self.parents:
			raise ValueError('{0} or {1} not in the set.'.format(x, y))
		x_rep = self.find(x)
		y_rep = self.find(y)
		if x_rep == y_rep:
			self.num_edges[x_rep] += 1
			return x_rep
		if self.rank(y_rep) > self.rank(x_rep):
			(x_rep, y_rep) = (y_rep, x_rep)
		self.parents[y_rep] = x_rep
		self.size[x_rep] += self.size[y_rep]
		self.num_components -= 1
		self.num_edges[x_rep] += 1 + self.num_edges[y_rep]
		return x_rep

	def find(self, x):
		if x not in self.parents:
			raise ValueError('{0} not in the set'.format(x))
		node = x
		while self.parents[node] != node:
			node = self.parents[node]
		while self.parents[x] != x:
			y = self.parents[x]
			self.parents[x] = node
			x = y
		return node

def main():
	(_, k) = mi(line())
	arr = lmi(line())
	arrs = set(arr)
	dsu = DSU(arr)
	for (e, n) in enumerate(arr):
		if n % k == 0:
			if n // k in arrs:
				dsu.union(n, n // k)
	ans = 0
	for par in dsu.parents:
		if dsu.find(par) == par:
			sz = dsu.size[par]
			if sz % 2 != 0:
				ans += sz // 2 + 1
			else:
				ans += sz // 2
	print(ans)
main()


R = lambda : map(int, input().split())
(n, k) = R()
arr = sorted(list(R()))
s = set(arr)
if k == 1:
	print(n)
else:
	for x in arr:
		if x in s and x * k in s:
			s.remove(x * k)
	print(len(s))


import math
import random
from queue import Queue
import time

def main(arr, k):
	set_arr = set(arr)
	max_val = max(arr)
	min_val = min(arr)
	arr.sort()
	if k == 1:
		return len(set_arr)
	f = {}
	for e in arr:
		if e not in f:
			f[e] = 0
		f[e] += 1
	ans = 0
	for e in arr:
		if e in set_arr:
			new_arr = []
			start_max = e
			while start_max <= max_val:
				if start_max in set_arr:
					set_arr.remove(start_max)
					new_arr.append(f[start_max])
				else:
					new_arr.append(0)
				start_max *= k
			dp = [[0 for j in range(2)] for i in range(len(new_arr))]
			dp[0][0] = 0
			dp[0][1] = new_arr[0]
			for i in range(1, len(dp)):
				for j in range(len(dp[0])):
					if j == 0:
						dp[i][j] = max(dp[i - 1][0], dp[i - 1][1])
					else:
						dp[i][j] = new_arr[i] + dp[i - 1][0]
			ans += max(dp[-1])
	return ans
(n, k) = list(map(int, input().split()))
arr = list(map(int, input().split()))
print(main(arr, k))


from sys import maxsize, stdout, stdin, stderr
mod = int(1000000000.0 + 7)
import sys

def I():
	return int(stdin.readline())

def lint():
	return [int(x) for x in stdin.readline().split()]

def S():
	return list(map(str, input().strip()))

def grid(r, c):
	return [lint() for i in range(r)]
from collections import defaultdict, Counter, deque
import math
import heapq
from heapq import heappop, heappush
import bisect
from itertools import groupby
from itertools import permutations as comb

def gcd(a, b):
	while b:
		a %= b
		tmp = a
		a = b
		b = tmp
	return a

def lcm(a, b):
	return a // gcd(a, b) * b

def check_prime(n):
	for i in range(2, int(n ** (1 / 2)) + 1):
		if not n % i:
			return False
	return True

def Bs(a, x):
	i = 0
	j = 0
	left = 1
	right = x
	flag = False
	while left < right:
		mi = (left + right) // 2
		if a[mi] <= x:
			left = mi + 1
			i += 1
		else:
			right = mi
			j += 1
	if left > 0 and a[left - 1] == x:
		return (i - 1, j)
	else:
		return (-1, -1)

def nCr(n, r):
	return fact(n) // (fact(r) * fact(n - r))

def fact(n):
	res = 1
	for i in range(2, n + 1):
		res = res * i
	return res

def primefactors(n):
	num = 0
	while n % 2 == 0:
		num += 1
		n = n / 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			num += 1
			n = n // i
	if n > 2:
		num += 1
	return num

def ask(a):
	print('? {}'.format(a), flush=True)
	n = I()
	return n

def dfs(i, p):
	(a, tmp) = (0, 0)
	for j in d[i]:
		if j != p:
			a += 1
			tmp += dfs(j, i)
	if a == 0:
		return 0
	return tmp / a + 1

def primeFactors(n):
	l = []
	while n % 2 == 0:
		l.append(2)
		n = n // 2
	if n > 2:
		l.append(n)
	return l
t = 1
for _ in range(t):
	(n, k) = lint()
	s = lint()
	d = Counter(s)
	s.sort()
	l = 0
	for i in range(n - 1, -1, -1):
		if d[s[i]]:
			if s[i] % k == 0:
				tmp = d[s[i] // k]
				if tmp:
					d[s[i] // k] = 0
			l += 1
	print(l)


from sys import stdin, stdout
from itertools import accumulate
nmbr = lambda : int(stdin.readline())
lst = lambda : list(map(int, stdin.readline().split()))
for _ in range(1):
	(n, k) = lst()
	a = lst()
	a.sort()
	s = set()
	for v in a:
		if v % k != 0 or v // k not in s:
			s.add(v)
	print(len(s))


from collections import Counter, defaultdict
BS = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'

def to_base(s, b):
	res = ''
	while s:
		res += BS[s % b]
		s //= b
	return res[::-1] or '0'
alpha = 'abcdefghijklmnopqrstuvwxyz'
from math import floor, ceil, pi
primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999, 2003, 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267, 2269, 2273, 2281, 2287, 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, 2437, 2441, 2447, 2459, 2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, 2609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903, 2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, 3023, 3037, 3041, 3049, 3061, 3067, 3079, 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167, 3169, 3181, 3187, 3191, 3203, 3209, 3217, 3221, 3229, 3251, 3253, 3257, 3259, 3271, 3299, 3301, 3307, 3313, 3319, 3323, 3329, 3331, 3343, 3347, 3359, 3361, 3371, 3373, 3389, 3391, 3407, 3413, 3433, 3449, 3457, 3461, 3463, 3467, 3469, 3491, 3499, 3511, 3517, 3527, 3529, 3533, 3539, 3541, 3547, 3557, 3559, 3571, 3581, 3583, 3593, 3607, 3613, 3617, 3623, 3631, 3637, 3643, 3659, 3671, 3673, 3677, 3691, 3697, 3701, 3709, 3719, 3727, 3733, 3739, 3761, 3767, 3769, 3779, 3793, 3797, 3803, 3821, 3823, 3833, 3847, 3851, 3853, 3863, 3877, 3881, 3889, 3907, 3911, 3917, 3919, 3923, 3929, 3931, 3943, 3947, 3967, 3989, 4001, 4003, 4007, 4013, 4019, 4021, 4027, 4049, 4051, 4057, 4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, 4133, 4139, 4153, 4157, 4159, 4177, 4201, 4211, 4217, 4219, 4229, 4231, 4241, 4243, 4253, 4259, 4261, 4271, 4273, 4283, 4289, 4297, 4327, 4337, 4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409, 4421, 4423, 4441, 4447, 4451, 4457, 4463, 4481, 4483, 4493, 4507, 4513, 4517, 4519, 4523, 4547, 4549, 4561, 4567, 4583, 4591, 4597, 4603, 4621, 4637, 4639, 4643, 4649, 4651, 4657, 4663, 4673, 4679, 4691, 4703, 4721, 4723, 4729, 4733, 4751, 4759, 4783, 4787, 4789, 4793, 4799, 4801, 4813, 4817, 4831, 4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931, 4933, 4937, 4943, 4951, 4957, 4967, 4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011, 5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087, 5099, 5101, 5107, 5113, 5119, 5147, 5153, 5167, 5171, 5179, 5189, 5197, 5209, 5227, 5231, 5233, 5237, 5261, 5273, 5279, 5281, 5297, 5303, 5309, 5323, 5333, 5347, 5351, 5381, 5387, 5393, 5399, 5407, 5413, 5417, 5419, 5431, 5437, 5441, 5443, 5449, 5471, 5477, 5479, 5483, 5501, 5503, 5507, 5519, 5521, 5527, 5531, 5557, 5563, 5569, 5573, 5581, 5591, 5623, 5639, 5641, 5647, 5651, 5653, 5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711, 5717, 5737, 5741, 5743, 5749, 5779, 5783, 5791, 5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849, 5851, 5857, 5861, 5867, 5869, 5879, 5881, 5897, 5903, 5923, 5927, 5939, 5953, 5981, 5987, 6007, 6011, 6029, 6037, 6043, 6047, 6053, 6067, 6073, 6079, 6089, 6091, 6101, 6113, 6121, 6131, 6133, 6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, 6217, 6221, 6229, 6247, 6257, 6263, 6269, 6271, 6277, 6287, 6299, 6301, 6311, 6317, 6323, 6329, 6337, 6343, 6353, 6359, 6361, 6367, 6373, 6379, 6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473, 6481, 6491, 6521, 6529, 6547, 6551, 6553, 6563, 6569, 6571, 6577, 6581, 6599, 6607, 6619, 6637, 6653, 6659, 6661, 6673, 6679, 6689, 6691, 6701, 6703, 6709, 6719, 6733, 6737, 6761, 6763, 6779, 6781, 6791, 6793, 6803, 6823, 6827, 6829, 6833, 6841, 6857, 6863, 6869, 6871, 6883, 6899, 6907, 6911, 6917, 6947, 6949, 6959, 6961, 6967, 6971, 6977, 6983, 6991, 6997, 7001, 7013, 7019, 7027, 7039, 7043, 7057, 7069, 7079, 7103, 7109, 7121, 7127, 7129, 7151, 7159, 7177, 7187, 7193, 7207, 7211, 7213, 7219, 7229, 7237, 7243, 7247, 7253, 7283, 7297, 7307, 7309, 7321, 7331, 7333, 7349, 7351, 7369, 7393, 7411, 7417, 7433, 7451, 7457, 7459, 7477, 7481, 7487, 7489, 7499, 7507, 7517, 7523, 7529, 7537, 7541, 7547, 7549, 7559, 7561, 7573, 7577, 7583, 7589, 7591, 7603, 7607, 7621, 7639, 7643, 7649, 7669, 7673, 7681, 7687, 7691, 7699, 7703, 7717, 7723, 7727, 7741, 7753, 7757, 7759, 7789, 7793, 7817, 7823, 7829, 7841, 7853, 7867, 7873, 7877, 7879, 7883, 7901, 7907, 7919]

def primef(n, plst=[]):
	if n == 1:
		return plst
	else:
		for m in primes:
			if n % m == 0:
				return primef(n // m, plst + [m])
		return primef(1, plst + [n])
(n, k) = list(map(int, input().split()))
nums = list(map(int, input().split()))
nums.sort(reverse=True)
s = set()
for i in range(n):
	if nums[i] * k not in s:
		s.add(nums[i])
print(len(s))


from sys import stdin
input = lambda : stdin.readline().strip()
from math import ceil, sqrt, factorial, gcd
from collections import deque
(n, k) = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
ans = set()
for i in l:
	if i % k != 0:
		ans.add(i)
	elif i // k in ans:
		pass
	else:
		ans.add(i)
print(len(ans))


import traceback
import math
from collections import defaultdict
from functools import lru_cache

def main():
	(N, k) = map(int, input().split())
	nums = list(map(int, input().split()))
	nums.sort()
	s = set(nums)
	g1 = g2 = 0
	done = set()
	for n in nums:
		if n in done:
			continue
		g1 += 1
		if n * k in s:
			g2 += 1
			done.add(n * k)
	return max(g1, g2)
ans = main()
print(ans)


def main():
	(n, k) = [int(x) for x in input().split(' ')]
	if k == 1:
		print(n)
		return
	a = []
	b = {}
	a = [int(x) for x in input().split(' ')]
	a.sort()
	a = dict(zip(a, range(n)))
	count = {}
	for x in a:
		if x % k == 0 and int(x / k) in a:
			b[x] = b[int(x / k)]
			count[b[int(x / k)]] += 1
		else:
			b[x] = x
			count[x] = 1
	for (x, y) in count.items():
		n -= int(y / 2)
	print(n)
main()


import sys, os, io

def rs():
	return sys.stdin.readline().rstrip()

def ri():
	return int(sys.stdin.readline())

def ria():
	return list(map(int, sys.stdin.readline().split()))

def ws(s):
	sys.stdout.write(s + '\n')

def wi(n):
	sys.stdout.write(str(n) + '\n')

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')
import math, datetime, functools, itertools, operator, bisect, fractions, statistics
from collections import deque, defaultdict, OrderedDict, Counter
from fractions import Fraction
from decimal import Decimal
from sys import stdout
from heapq import heappush, heappop, heapify, _heapify_max, _heappop_max, nsmallest, nlargest
sys.setrecursionlimit(111111)
INF = 999999999999999999999999

class SortedList:

	def __init__(self, iterable=[], _load=200):
		values = sorted(iterable)
		self._len = _len = len(values)
		self._load = _load
		self._lists = _lists = [values[i:i + _load] for i in range(0, _len, _load)]
		self._list_lens = [len(_list) for _list in _lists]
		self._mins = [_list[0] for _list in _lists]
		self._fen_tree = []
		self._rebuild = True

	def _fen_build(self):
		self._fen_tree[:] = self._list_lens
		_fen_tree = self._fen_tree
		for i in range(len(_fen_tree)):
			if i | i + 1 < len(_fen_tree):
				_fen_tree[i | i + 1] += _fen_tree[i]
		self._rebuild = False

	def _fen_update(self, index, value):
		if not self._rebuild:
			_fen_tree = self._fen_tree
			while index < len(_fen_tree):
				_fen_tree[index] += value
				index |= index + 1

	def _fen_query(self, end):
		if self._rebuild:
			self._fen_build()
		_fen_tree = self._fen_tree
		x = 0
		while end:
			x += _fen_tree[end - 1]
			end &= end - 1
		return x

	def _fen_findkth(self, k):
		_list_lens = self._list_lens
		if k < _list_lens[0]:
			return (0, k)
		if k >= self._len - _list_lens[-1]:
			return (len(_list_lens) - 1, k + _list_lens[-1] - self._len)
		if self._rebuild:
			self._fen_build()
		_fen_tree = self._fen_tree
		idx = -1
		for d in reversed(range(len(_fen_tree).bit_length())):
			right_idx = idx + (1 << d)
			if right_idx < len(_fen_tree) and k >= _fen_tree[right_idx]:
				idx = right_idx
				k -= _fen_tree[idx]
		return (idx + 1, k)

	def _delete(self, pos, idx):
		_lists = self._lists
		_mins = self._mins
		_list_lens = self._list_lens
		self._len -= 1
		self._fen_update(pos, -1)
		del _lists[pos][idx]
		_list_lens[pos] -= 1
		if _list_lens[pos]:
			_mins[pos] = _lists[pos][0]
		else:
			del _lists[pos]
			del _list_lens[pos]
			del _mins[pos]
			self._rebuild = True

	def _loc_left(self, value):
		if not self._len:
			return (0, 0)
		_lists = self._lists
		_mins = self._mins
		(lo, pos) = (-1, len(_lists) - 1)
		while lo + 1 < pos:
			mi = lo + pos >> 1
			if value <= _mins[mi]:
				pos = mi
			else:
				lo = mi
		if pos and value <= _lists[pos - 1][-1]:
			pos -= 1
		_list = _lists[pos]
		(lo, idx) = (-1, len(_list))
		while lo + 1 < idx:
			mi = lo + idx >> 1
			if value <= _list[mi]:
				idx = mi
			else:
				lo = mi
		return (pos, idx)

	def _loc_right(self, value):
		if not self._len:
			return (0, 0)
		_lists = self._lists
		_mins = self._mins
		(pos, hi) = (0, len(_lists))
		while pos + 1 < hi:
			mi = pos + hi >> 1
			if value < _mins[mi]:
				hi = mi
			else:
				pos = mi
		_list = _lists[pos]
		(lo, idx) = (-1, len(_list))
		while lo + 1 < idx:
			mi = lo + idx >> 1
			if value < _list[mi]:
				idx = mi
			else:
				lo = mi
		return (pos, idx)

	def add(self, value):
		_load = self._load
		_lists = self._lists
		_mins = self._mins
		_list_lens = self._list_lens
		self._len += 1
		if _lists:
			(pos, idx) = self._loc_right(value)
			self._fen_update(pos, 1)
			_list = _lists[pos]
			_list.insert(idx, value)
			_list_lens[pos] += 1
			_mins[pos] = _list[0]
			if _load + _load < len(_list):
				_lists.insert(pos + 1, _list[_load:])
				_list_lens.insert(pos + 1, len(_list) - _load)
				_mins.insert(pos + 1, _list[_load])
				_list_lens[pos] = _load
				del _list[_load:]
				self._rebuild = True
		else:
			_lists.append([value])
			_mins.append(value)
			_list_lens.append(1)
			self._rebuild = True

	def discard(self, value):
		_lists = self._lists
		if _lists:
			(pos, idx) = self._loc_right(value)
			if idx and _lists[pos][idx - 1] == value:
				self._delete(pos, idx - 1)

	def remove(self, value):
		_len = self._len
		self.discard(value)
		if _len == self._len:
			raise ValueError('{0!r} not in list'.format(value))

	def pop(self, index=-1):
		(pos, idx) = self._fen_findkth(self._len + index if index < 0 else index)
		value = self._lists[pos][idx]
		self._delete(pos, idx)
		return value

	def bisect_left(self, value):
		(pos, idx) = self._loc_left(value)
		return self._fen_query(pos) + idx

	def bisect_right(self, value):
		(pos, idx) = self._loc_right(value)
		return self._fen_query(pos) + idx

	def count(self, value):
		return self.bisect_right(value) - self.bisect_left(value)

	def __len__(self):
		return self._len

	def __getitem__(self, index):
		(pos, idx) = self._fen_findkth(self._len + index if index < 0 else index)
		return self._lists[pos][idx]

	def __delitem__(self, index):
		(pos, idx) = self._fen_findkth(self._len + index if index < 0 else index)
		self._delete(pos, idx)

	def __contains__(self, value):
		_lists = self._lists
		if _lists:
			(pos, idx) = self._loc_left(value)
			return idx < len(_lists[pos]) and _lists[pos][idx] == value
		return False

	def __iter__(self):
		return (value for _list in self._lists for value in _list)

	def __reversed__(self):
		return (value for _list in reversed(self._lists) for value in reversed(_list))

	def __repr__(self):
		return 'SortedList({0})'.format(list(self))

def main():
	mod = 1000000007
	starttime = datetime.datetime.now()
	if os.path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	tc = 1
	for _ in range(tc):
		(n, k) = ria()
		a = ria()
		a = sorted(a)
		d = Counter(a)
		ans = 0
		for i in a:
			if d[i]:
				ans += 1
				d[i * k] = 0
		wi(ans)
	endtime = datetime.datetime.now()
	time = (endtime - starttime).total_seconds() * 1000
	if os.path.exists('input.txt'):
		print('Time:', time, 'ms')

class FastReader(io.IOBase):
	newlines = 0

	def __init__(self, fd, chunk_size=1024 * 8):
		self._fd = fd
		self._chunk_size = chunk_size
		self.buffer = io.BytesIO()

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self, size=-1):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size if size == -1 else size))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

class FastWriter(io.IOBase):

	def __init__(self, fd):
		self._fd = fd
		self.buffer = io.BytesIO()
		self.write = self.buffer.write

	def flush(self):
		os.write(self._fd, self.buffer.getvalue())
		(self.buffer.truncate(0), self.buffer.seek(0))

class FastStdin(io.IOBase):

	def __init__(self, fd=0):
		self.buffer = FastReader(fd)
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

class FastStdout(io.IOBase):

	def __init__(self, fd=1):
		self.buffer = FastWriter(fd)
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.flush = self.buffer.flush
sys.stdin = FastStdin()
sys.stdout = FastStdout()
main()


(n, k) = list(map(int, input().split()))
arr = list(map(int, input().split()))
arr.sort()
ans = set()
for x in arr:
	if x % k == 0:
		t = x // k
		if t not in ans:
			ans.add(x)
	else:
		ans.add(x)
print(len(ans))


import math, sys, os
from io import BytesIO, IOBase
mod = 10 ** 9 + 7
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def minp():
	return map(int, sys.stdin.readline().rstrip().split())

def linp():
	return list(map(int, sys.stdin.readline().rstrip().split()))

def inp():
	return int(input())

def print_list(l):
	print(' '.join(map(str, l)))
(n, k) = minp()
a = linp()
a.sort()
s = set()
for i in a:
	if i % k:
		s.add(i)
	elif i // k not in s:
		s.add(i)
print(len(s))


from bisect import bisect_left
import os
import sys
from io import BytesIO, IOBase
from collections import Counter, defaultdict
from collections import deque
from functools import cmp_to_key
import math
import heapq
import re

def sin():
	return input()

def ain():
	return list(map(int, sin().split()))

def sain():
	return input().split()

def iin():
	return int(sin())
MAX = float('inf')
MIN = float('-inf')
MOD = 1000000007

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	s = set()
	for p in range(2, n + 1):
		if prime[p]:
			s.add(p)
	return s

def readTree(n, m):
	adj = [deque([]) for _ in range(n + 1)]
	for _ in range(m):
		(u, v) = ain()
		adj[u].append(v)
		adj[v].append(u)
	return adj

def main():
	(n, k) = ain()
	l = ain()
	l.sort()
	s = set()
	for i in l:
		if i % k == 0:
			if i // k not in s:
				s.add(i)
		else:
			s.add(i)
	print(len(s))
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
if os.getcwd() == 'D:\\code':
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
	input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


(n, k) = map(int, input().split())
seq = sorted((int(c) for c in input().split()))
seq_set = set()
for (i, d) in enumerate(seq):
	if d % k:
		seq_set.add(d)
	elif d // k not in seq_set:
		seq_set.add(d)
print(len(seq_set))


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
d = {}
for i in range(n):
	d[a[i]] = 1
a.sort(reverse=True)
ans = 0
for i in range(n):
	if d[a[i]] > 0:
		if a[i] % k == 0:
			x = a[i] // k
			if x in d:
				d[x] -= 1
		ans += 1
print(ans)


import sys
import math
from collections import defaultdict

def solve(test):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	rec = set()
	for i in range(n):
		if a[i] * k not in rec:
			rec.add(a[i])
	ans = len(rec)
	print(ans)
test_cases = 1
for t in range(1, test_cases + 1):
	solve(t)


import os
import sys
from io import BytesIO, IOBase
import heapq as h
from bisect import bisect_left, bisect_right
from types import GeneratorType
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		import os
		self.os = os
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			self.os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import collections as col
import math

def getInts():
	return [int(s) for s in input().split()]

def getInt():
	return int(input())

def getStrs():
	return [s for s in input().split()]

def getStr():
	return input()

def listStr():
	return list(input())
MOD = 10 ** 9 + 7

def solve():
	(N, K) = getInts()
	A = getInts()
	ans = set()
	A.sort()
	for a in A:
		if a % K > 0 or a // K not in ans:
			ans.add(a)
	return len(ans)
print(solve())


def sfun(n, k, lst):
	s = {}
	for i in range(n):
		if lst[i] * k in s:
			continue
		s[lst[i]] = 1
	return len(s)
(N, K) = [int(j) for j in input().split()]
a = [int(x) for x in input().split()]
print(sfun(N, K, sorted(a, reverse=True)))


(n, k) = map(int, input().split())
a = sorted(list(map(int, input().split())))
ans = []
for i in range(n):
	if a[i] % k != 0:
		ans.append(a[i])
	elif a[i] // k not in ans:
		ans.append(a[i])
print(len(ans))


import math
import sys
import collections
import bisect
import string
import time

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_list():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_string():
	return sys.stdin.readline().strip()
for t in range(1):
	(n, k) = get_ints()
	arr = get_list()
	arr.sort()
	ans = set()
	for i in arr:
		if i % k != 0:
			ans.add(i)
		elif i // k not in ans:
			ans.add(i)
	print(len(ans))


(n, k) = map(int, input().split())
s = set()
l = [int(i) for i in input().split()]
l.sort()
for i in l:
	if i % k:
		s.add(i)
	elif i // k in s:
		pass
	else:
		s.add(i)
print(len(s))


(n, k) = [int(x) for x in input().split()]
a = sorted([int(x) for x in input().split()])
s = set(a)
l = 0
for x in a:
	t = 1
	while x in s:
		l += t
		t = 1 - t
		s.remove(x)
		x *= k
print(l)


(n, k) = [int(x) for x in input().split()]
arr = [int(x) for x in input().split()]
arr.sort()
d = {}
for i in arr:
	if i % k == 0 and i // k in d:
		d[i] = d[i // k] + 1
		del d[i // k]
	else:
		d[i] = 1
ans = 0
for i in d:
	if d[i] % 2:
		ans += d[i] // 2 + 1
	else:
		ans += d[i] // 2
print(ans)


def main():
	(n, k) = map(int, input().split())
	if n == 1:
		print(1)
		return
	l = sorted(map(int, input().split()))
	baned = set()
	s = set(l)
	if k > 1:
		for p in l:
			if p not in baned:
				p *= k
				s.discard(p)
				baned.add(p)
	print(len(s))

def __starting_point():
	main()
__starting_point()


import bisect

def binary_search(a, l):
	p = bisect.bisect_left(a, l)
	try:
		if a[p] == l:
			return True
		else:
			return False
	except:
		return False
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a = sorted(a)
i = 0
if k == 1:
	print(len(a))
	exit()
while True:
	if i == len(a):
		break
	if binary_search(a, k * a[i]) == True:
		pos = bisect.bisect_left(a, k * a[i])
		del a[pos]
	else:
		i += 1
print(len(a))


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
l = l[::-1]
d = {}
for i in range(0, n):
	if l[i] * k in d:
		continue
	d[l[i]] = 1
print(len(d))


from math import ceil
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()

def search(a, t):
	l = 0
	r = len(a) - 1
	while r - l >= 0:
		mid = (l + r) // 2
		if a[mid] == t:
			return mid
		if a[mid] < t:
			l = mid + 1
		if a[mid] > t:
			r = mid - 1
	return -1
if k == 1:
	print(n)
else:
	v = [0] * n
	groups = []
	it = 0
	for i in range(n):
		if not v[i]:
			q = a[i]
			g = []
			while search(a, q) != -1:
				v[search(a, q)] = 1
				g.append(q)
				q *= k
			groups.append(g)
	ct = 0
	for g in groups:
		ct += int(ceil(len(g) / 2))
	print(ct)


(n, k) = (int(x) for x in input().split())
a = [int(x) for x in input().split()]
exclude = set()
ans = 0
a.sort()
for i in a:
	if i not in exclude:
		exclude.add(i * k)
		ans += 1
print(ans)


(a, b) = map(int, input().split(' '))
ints = list(map(int, input().split(' ')))
ints.sort()
dictionary = {}
for num in ints:
	if num / b % 1 != 0:
		dictionary[num] = 1
	elif int(num / b) not in dictionary:
		dictionary[num] = 1
print(len(dictionary))


(n, k) = map(int, input().split())
p = [int(x) for x in input().split()]
s = []
p = sorted(p)
for i in range(0, n):
	if p[i] % k != 0:
		s.append(p[i])
	elif int(p[i] / k) not in s:
		s.append(p[i])
print(len(s))


import os
import sys
from math import *
from collections import *
from fractions import *
from bisect import *
from heapq import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]
(n, k) = value()
seen = set()
related = {}
a = set(array())
ans = 0
if k == 1:
	print(n)
	exit()
for i in sorted(a):
	if i not in seen:
		related[i] = [i]
		j = i * k
		while j in a:
			related[i].append(j)
			seen.add(j)
			j *= k
		ans += ceil(len(related[i]) / 2)
print(ans)


(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
arr.sort()
ans = set()
for i in arr:
	if i % k:
		ans.add(i)
	elif i // k not in ans:
		ans.add(i)
print(len(ans))


(n, k) = map(int, input().split())
a = sorted(map(int, input().split()))
(t, r) = ({}, 0)
for i in a:
	if i not in t:
		t[i] = 1
		r += 1
	if t[i]:
		t[i * k] = 0
print(r)


(n, k) = map(int, input().split())
a = [*map(int, input().split())]
a.sort()

def binary_search(arr, value):
	(first, last) = (0, len(arr) - 1)
	while first <= last:
		mid = (first + last) // 2
		if arr[mid] == value:
			return mid
		elif arr[mid] < value:
			first = mid + 1
		else:
			last = mid - 1
	return -1
ans = 0
for i in range(n):
	if a[i] != -1:
		ans += 1
		id = binary_search(a, a[i] * k)
		if id != -1:
			a[id] = -1
print(ans)


import sys
input = sys.stdin.readline
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
s = set()
a.sort()
for i in range(n):
	if a[i] % k != 0:
		s.add(a[i])
	elif a[i] // k not in s:
		s.add(a[i])
print(len(s))


(n, k) = list(map(int, input().split()))
nums = list(map(int, input().split()))
if k == 1:
	print(len(nums))
else:
	r = set()
	for i in sorted(nums):
		if i in r:
			continue
		else:
			r.add(i * k)
	print(len([i for i in nums if i not in r]))


(n, k) = map(int, input().split())
a = sorted(map(int, input().split()))
has = set()
ret = []
for v in a:
	if v % k != 0 or v // k not in has:
		ret.append(v)
		has.add(v)
print(len(ret))


(n, k) = map(int, input().split())
lis = [0] + sorted(map(int, input().split()))
kk = lis[:]
ans = 0
for i in range(n, -1, -1):
	l = 0
	r = i
	if kk[i] == 0:
		continue
	while l <= r:
		mid = l + (r - l) // 2
		if lis[i] / k < lis[mid]:
			r = mid - 1
		else:
			l = mid + 1
	if lis[r] * 10 == lis[i] / k * 10:
		kk[r] = 0
	ans += 1
print(ans)


import traceback
import math
from collections import defaultdict
from functools import lru_cache

def main():
	(N, k) = map(int, input().split())
	nums = list(map(int, input().split()))
	nums.sort()
	s = set(nums)
	(g1, g2) = ([], [])
	done = set()
	for n in nums:
		if n in done:
			g2.append(n * k)
		else:
			g1.append(n)
			if n * k in s:
				done.add(n * k)
	return len(max([g1, g2], key=len))
ans = main()
print(ans)


(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
arr.sort()
s = set()
ans = 0
for c in arr:
	if c % k == 0 and c // k in s:
		continue
	else:
		ans += 1
		s.add(c)
print(ans)


(n, k) = map(int, input().split())
seq_set = set()
for e in sorted((int(c) for c in input().split())):
	if e % k or e // k not in seq_set:
		seq_set.add(e)
print(len(seq_set))


def bb(A, item):
	(esquerda, direita) = (0, len(A) - 1)
	while esquerda <= direita:
		meio = (esquerda + direita) // 2
		if A[meio] == item:
			return meio
		elif A[meio] > item:
			direita = meio - 1
		elif A[meio] < item:
			esquerda = meio + 1
	return -1
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
menores = []
maiores = []
for i in range(n):
	if bb(menores, a[i]) == -1:
		if bb(maiores, a[i]) == -1:
			menores.append(a[i])
			maiores.append(a[i] * k)
		else:
			continue
print(len(menores))


import os
import sys
from math import *
from collections import *
from fractions import *
from bisect import *
from heapq import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]

def possible():
	flag = defaultdict(bool)
	c = 0
	for i in a:
		if i % k != 0 or not flag[i // k]:
			c += 1
			flag[i] = True
	return c
for _ in range(1):
	(n, k) = value()
	a = sorted(array())
	print(possible())


(n, k) = map(int, input().split())
arr = sorted(list(map(int, input().split())))
if k == 1:
	print(n)
	exit()
res = set(arr)
for x in arr:
	if x in res:
		res.discard(x * k)
print(len(res))


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
res = set()
for i in l:
	if i % k == 0 and i / k in res:
		pass
	else:
		res.add(i)
print(len(res))


from sys import stdin

def main():
	(n, k) = map(int, stdin.readline().split())
	ar = list(map(int, stdin.readline().split()))
	if k == 1:
		print(n)
	else:
		ar.sort()
		lk = set()
		check = {}
		for elm in ar:
			lk.add(elm)
			check[elm] = False
		ans = 0
		max_val = ar[-1]
		for i in range(n):
			if not check[ar[i]]:
				cnt = 0
				curr = ar[i]
				while curr <= max_val and curr in lk:
					cnt += 1
					check[curr] = True
					curr = curr * k
				ans += cnt // 2 + cnt % 2
		print(ans)
main()


import bisect
from itertools import accumulate
import os
import sys
import math
from decimal import *
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def SieveOfEratosthenes(n):
	prime = []
	primes = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if primes[p] == True:
			prime.append(p)
			for i in range(p * p, n + 1, p):
				primes[i] = False
		p += 1
	return prime

def primefactors(n):
	fac = []
	while n % 2 == 0:
		fac.append(2)
		n = n // 2
	for i in range(3, int(math.sqrt(n)) + 2):
		while n % i == 0:
			fac.append(i)
			n = n // i
	if n > 1:
		fac.append(n)
	return sorted(fac)

def factors(n):
	fac = set()
	fac.add(1)
	fac.add(n)
	for i in range(2, int(math.sqrt(n)) + 1):
		if n % i == 0:
			fac.add(i)
			fac.add(n // i)
	return list(fac)

def modInverse(a, m):
	m0 = m
	y = 0
	x = 1
	if m == 1:
		return 0
	while a > 1:
		q = a // m
		t = m
		m = a % m
		a = t
		t = y
		y = x - q * y
		x = t
	if x < 0:
		x = x + m0
	return x
(n, k) = map(int, input().split())
a = list(sorted(map(int, input().split()), reverse=True))
s = set()
for i in range(len(a)):
	if a[i] * k not in s:
		s.add(a[i])
print(len(s))


first_multiple_input = input().rstrip().split()
n = int(first_multiple_input[0])
k = int(first_multiple_input[1])
element = list(map(int, input().rstrip().split()))
element.sort()
cross = set(element)
for i in element:
	if i in cross:
		if i * k in cross:
			cross.remove(i * k)
if k == 1:
	print(len(element))
else:
	print(len(cross))


(n, k) = [int(e) for e in input().split()]
a = sorted([int(e) for e in input().split()])
s = set()
for i in range(n):
	if a[i] % k != 0:
		s.add(a[i])
	elif a[i] / k not in s:
		s.add(a[i])
print(len(s))


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
p = []
a = sorted(l)
for i in a:
	if i % k == 0:
		if i // k in p:
			pass
		else:
			p.append(i)
	else:
		p.append(i)
print(len(set(p)))


from sys import stdin
(n, k) = map(int, stdin.readline().split())
nums = list(map(int, stdin.readline().split()))
nums.sort()
count = 0
new = set()
for i in nums:
	if i % k:
		new.add(i)
	elif i // k in new:
		pass
	else:
		new.add(i)
print(len(new))