/* practice with Dukkha */
#include <stdio.h>

int query(int i, int j) {
	static char s[4];

	printf("1 %d %d\n", i, j);
	fflush(stdout);
	scanf("%s", s);
	return s[0] == 'T';
}

int search(int lower, int upper) {
	while (upper - lower > 1) {
		int i = (lower + upper) / 2;

		if (query(i, i + 1))
			upper = i;
		else
			lower = i;
	}
	return upper;
}

int search_(int lower, int upper) {
	while (upper - lower > 1) {
		int i = (lower + upper) / 2;

		if (query(i + 1, i))
			lower = i;
		else
			upper = i;
	}
	return upper;
}

int main() {
	int n, k, i, j;

	scanf("%d%d", &n, &k);
	i = search(0, n);
	j = search(0, i - 1);
	if (j == 0 || !query(j, i))
		j = search_(i + 1, n);
	printf("2 %d %d\n", i, j);
	fflush(stdout);
	return 0;
}


/* practice with Dukkha */
#include <stdio.h>

int query(int i, int j) {
	static char s[4];

	printf("1 %d %d\n", i, j);
	fflush(stdout);
	scanf("%s", s);
	return s[0] == 'T';
}

int search(int lower, int upper) {
	while (upper - lower > 1) {
		int i = (lower + upper) / 2;

		if (query(i, i + 1))
			upper = i;
		else
			lower = i;
	}
	return upper;
}

int search_(int lower, int upper) {
	while (upper - lower > 1) {
		int i = (lower + upper) / 2;

		if (query(i + 1, i))
			lower = i;
		else
			upper = i;
	}
	return upper;
}

int main() {
	int n, k, i, j;

	scanf("%d%d", &n, &k);
	i = search(0, n);
	j = search(0, i - 1);
	if (j == 0 || !query(j, i))
		j = search_(i, n);
	printf("2 %d %d\n", i, j);
	fflush(stdout);
	return 0;
}


/* practice with Dukkha */
#include <stdio.h>

int query(int i, int j) {
	static char s[4];

	printf("1 %d %d\n", i, j);
	fflush(stdout);
	scanf("%s", s);
	return s[0] == 'T';
}

int search(int lower, int upper) {
	while (upper - lower > 1) {
		int i = (lower + upper) / 2;

		if (query(i, i + 1))
			upper = i;
		else
			lower = i;
	}
	return upper;
}

int main() {
	int n, k, i, j;

	scanf("%d%d", &n, &k);
	i = search(0, n);
	j = search(0, i - 1);
	if (j == 0 || !query(j, i))
		j = search(i, n);
	printf("2 %d %d\n", i, j);
	fflush(stdout);
	return 0;
}


package main

import "fmt"

func tak(x, y int) bool {
	fmt.Println(1, x, y)
	var ans string
	fmt.Scan(&ans)
	return ans == "TAK"
}

func search(lo, hi int) int {
	for hi-lo >= 3 {
		x := lo + (hi-lo)/3
		y := x + (hi-lo)/3
		if tak(x, y) {
			hi = y - 1
		} else {
			lo = x + 1
		}
	}
	switch hi - lo {
	case 2:
		a := tak(lo, lo+1)
		b := tak(lo, lo+2)
		switch {
		case a && b:
			return lo
		case a && !b:
			return lo + 2
		case !a && b:
			return lo + 1
		default:
			return lo + 2
		}
	case 1:
		if tak(lo, lo+1) {
			return lo
		}
		return lo + 1
	}
	return lo
}

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	a := search(1, n)
	if a-1 < n-a {
		mi := a - 1
		if tak(a+mi, a-mi) {
			fmt.Println(2, a, search(a+1, n))
		} else {
			fmt.Println(2, a, search(1, a-1))
		}
	} else {
		mi := n - a
		if tak(a-mi, a+mi) {
			fmt.Println(2, a, search(1, a-1))
		} else {
			fmt.Println(2, a, search(a+1, n))
		}
	}

}


package main

import "fmt"

func tak(x, y int) bool {
	fmt.Println(1, x, y)
	var ans string
	fmt.Scan(&ans)
	return ans == "TAK"
}

func search(lo, hi int) int {
	for hi-lo >= 3 {
		x := lo + (hi-lo)/3
		y := hi - (hi-lo)/3
		if tak(x, y) {
			hi = y - 1
		} else {
			lo = x + 1
		}
	}
	switch hi - lo {
	case 2:
		a := tak(lo, lo+1)
		b := tak(lo, lo+2)
		switch {
		case a && b:
			return lo
		case a && !b:
			return lo + 2
		case !a && b:
			return lo + 1
		default:
			return lo + 2
		}
	case 1:
		if tak(lo, lo+1) {
			return lo
		}
		return lo + 1
	}
	return lo
}

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	a := search(1, n)
	if a-1 < n-a {
		mi := a - 1
		if tak(a+mi, a-mi) {
			fmt.Println(2, a, search(a+1, n))
		} else {
			fmt.Println(2, a, search(1, a-1))
		}
	} else {
		mi := n - a
		if tak(a-mi, a+mi) {
			fmt.Println(2, a, search(1, a-1))
		} else {
			fmt.Println(2, a, search(a+1, n))
		}
	}

}


import sys
range = xrange
input = raw_input

# x dist <= y dist
def query(x,y):
    print 1, x + 1, y + 1
    sys.stdout.flush()
    return input() == 'TAK'

def solve(x,y):
    print 2,x+1,y+1
    sys.exit()

n,k = [int(x) for x in input().split()]

a = 0
b = n - 1
while a<b:
    c = a + b >> 1
    if query(c,c+1):
        b = c
    else:
        a = c + 1
# first found at a
pos1 = a

a = 0
b = pos1 - 1
while a < b:
    c = a + b >> 1
    if query(c,c+1):
        b = c
    else:
        a = c + 1

if a == b and query(a, pos1):
    pos2 = a
else:
    a = pos1 + 1
    b = n - 1
    while a < b:
        c = a + b >> 1
        if query(c + 1, c):
            a = c + 1
        else:
            b = c
    pos2 = a

solve(pos1, pos2)


def get(x, y):
    print(1, x, y)
    #return int(min(abs(x - pos) for pos in a) <= min(abs(y - pos) for pos in a))
    return int(input() == 'TAK')
read = lambda: map(int, input().split())
n, k = read()
#from random import randint
#a = [randint(n - 100, n) for i in range(k)]
#a = list(read()) #

l = 1
r = n
while r - l > 3:
    m = (l + r) >> 1
    d = (r - l + 1) // 4
    m1 = l + d
    m2 = r - d
    res = get(m1, m2)

    if res: r = m + 1
    else: l = m - 1
p = [get(i, i + 1) for i in range(l, min(n, r + 1))]
for i in range(len(p) - 1):
    if p[i] == 0 and p[i + 1] == 1:
        ans1 = l + i + 1
        break
else:
    ans1 = l

#print('ans1 =', ans1)

l = ans1 + 1
r = n
while r - l > 3:
    m = (l + r) >> 1
    d = (r - l + 1) // 4
    m1 = l + d
    m2 = r - d
    res = get(m1, m2)
    if res: r = m + 1
    else: l = m - 1
p = [get(i, i + 1) for i in range(l, min(n, r + 1))]
for i in range(len(p) - 1):
    if p[i] == 0 and p[i + 1] == 1:
        ans2 = l + i + 1
        break
else:
    ans2 = l if p[0] else r

print(2, ans1, ans2)#, ans1 in a and ans2 in a)


def get(x, y):
    print(1, x, y)
    #return int(min(abs(x - pos) for pos in a) <= min(abs(y - pos) for pos in a))
    return int(input() == 'TAK')
read = lambda: map(int, input().split())
n, k = read()
#from random import randint
#a = [randint(n - 100, n) for i in range(k)]
#a = list(read()) #

l = 1
r = n
while r - l > 3:
    m = (l + r) >> 1
    d = (r - l + 1) // 4
    m1 = l + d
    m2 = r - d
    res = get(m1, m2)
    if res: r = m + 1
    else: l = m - 1
p = [get(i, i + 1) for i in range(l, min(n, r + 1))]
for i in range(len(p) - 1):
    if p[i] == 0 and p[i + 1] == 1:
        ans1 = l + i + 1
        break
else:
    ans1 = l

l = ans1 + 1
r = n
while r - l > 3:
    m = (l + r) >> 1
    d = (r - l + 1) // 4
    m1 = l + d
    m2 = r - d
    res = get(m1, m2)
    if res: r = m + 1
    else: l = m - 1
p = [get(i, i + 1) for i in range(l, min(n, r + 1))]
for i in range(len(p) - 1):
    if p[i] == 0 and p[i + 1] == 1:
        ans2 = l + i + 1
        break
else:
    ans2 = l if len(p) and p[0] else r

print(2, ans1, ans2)#, ans1 in a and ans2 in a)
exit()


def get(l, r):
    print(1, l, r)
    return input() == 'TAK'
def f(l, r):
    while l < r:
        m = (l + r) >> 1
        res = get(m, m + 1)
        if res: r = m
        else: l = m + 1
    return l
n, k = map(int, input().split())
x = f(1, n)
y = f(1, x - 1)
if get(1, y, x): y = f(x + 1, n)
print(2, x, y)
exit()


def get(x, y):
    print(1, x, y)
    #return int(min(abs(x - pos) for pos in a) <= min(abs(y - pos) for pos in a))
    return int(input() == 'TAK')
read = lambda: map(int, input().split())
n, k = read()
#from random import randint
#a = [randint(n - 100, n) for i in range(k)]
#a = list(read()) #

l = 1
r = n
while r - l > 3:
    m = (l + r) >> 1
    d = (r - l + 1) // 4
    m1 = l + d
    m2 = r - d
    res = get(m1, m2)

    if res: r = m + 1
    else: l = m - 1
p = [get(i, i + 1) for i in range(l, min(n, r + 1))]
for i in range(len(p) - 1):
    if p[i] == 0 and p[i + 1] == 1:
        ans1 = l + i + 1
        break
else:
    ans1 = l

#print('ans1 =', ans1)

l = ans1 + 1
r = n
while r - l > 3:
    m = (l + r) >> 1
    d = (r - l + 1) // 4
    m1 = l + d
    m2 = r - d
    res = get(m1, m2)
    if res: r = m + 1
    else: l = m - 1
p = [get(i, i + 1) for i in range(l, min(n, r + 1))]
for i in range(len(p) - 1):
    if p[i] == 0 and p[i + 1] == 1:
        ans2 = l + i + 1
        break
else:
    ans2 = l

print(2, ans1, ans2, ans1 in a and ans2 in a)


def get(l, r):
    print(1, l, r)
    return input() == 'TAK'
def f(l, r):
    while l < r:
        m = (l + r) >> 1
        if get(m, m + 1): r = m
        else: l = m + 1
    return l
n, k = map(int, input().split())
x = f(1, n)
y = f(1, x - 1)
if x == y or not get(y, x):
    y = f(x + 1, n)
print(2, x, y)
exit()


def get(x, y):
    print(1, x, y)
    return int(min(abs(x - pos) for pos in a) <= min(abs(y - pos) for pos in a))
    #return int(input() == 'TAK')
read = lambda: map(int, input().split())
n, k = read()
#from random import randint
#a = [randint(n - 100, n) for i in range(k)]
a = list(read()) #

l = 1
r = n
while r - l > 3:
    m = (l + r) >> 1
    d = (r - l + 1) // 4
    m1 = l + d
    m2 = r - d
    res = get(m1, m2)
    if res: r = m + 1
    else: l = m - 1
p = [get(i, i + 1) for i in range(l, min(n, r + 1))]
for i in range(len(p) - 1):
    if p[i] == 0 and p[i + 1] == 1:
        ans1 = l + i + 1
        break
else:
    ans1 = l

l = ans1 + 1
r = n
while r - l > 3:
    m = (l + r) >> 1
    d = (r - l + 1) // 4
    m1 = l + d
    m2 = r - d
    res = get(m1, m2)
    if res: r = m + 1
    else: l = m - 1
p = [get(i, i + 1) for i in range(l, min(n, r + 1))]
for i in range(len(p) - 1):
    if p[i] == 0 and p[i + 1] == 1:
        ans2 = l + i + 1
        break
else:
    ans2 = l if p[0] else r

print(2, ans1, ans2, ans1 in a and ans2 in a)
exit()


//Glad to see you!
import java.io.*
import java.util.*
import kotlin.math.*
//semi-t
fun main(){
	val f = BufferedReader(InputStreamReader(System.`in`))

	val (n,m) = f.readLine().split(" ").map{it.toInt()}

	fun find(ll : Int, rr : Int) : Int{
		if(ll > rr) return -1
		if(ll == rr){
			if(ll == n){
				println("1 $n ${n-1}")
				System.out.flush()

				val s = f.readLine()
				if(s.equals("TAK")){
					return ll
				} else {
					return -1
				}
			} else {
				println("1 $ll ${ll+1}")
				System.out.flush()

				val s = f.readLine()
				if(s.equals("TAK")){
					return ll
				} else {
					return -1
				}
			}
		}

		var l = ll
		var r = rr
		var ans = -1
		while(l < r){
			val mid = l + (r-l)/2

			println("1 ${mid} ${mid+1}")
			System.out.flush()

			val s = f.readLine()

			if(s.equals("TAK")){
				//left
				ans = mid
				r = mid
			} else {
				ans = mid+1
				l = mid+1
			}
		}

		if(ans == ll && ans > 1){
			println("1 ${ans-1} ${ans}")
			System.out.flush()

			val s = f.readLine()

			if(s.equals("TAK")){
				return -1
			}
		} else if(ans == rr && ans < n){
			println("1 $ans ${ans+1}")
			System.out.flush()

			val s = f.readLine()

			if(s.equals("NIE")){
				return -1
			}
		}

		return ans
	}

	val a1 = find(1,n)

	val a2a = find(1,a1-1)
	val a2b = find(a1+1,n)

	if(a2a == -1) println("2 $a1 $a2b")
	else println("2 $a1 $a2a")

}


//Glad to see you!
import java.io.*
import java.util.*
import kotlin.math.*
//semi-t
fun main(){
	val f = BufferedReader(InputStreamReader(System.`in`))

	val (n,m) = f.readLine().split(" ").map{it.toInt()}

	fun find(ll : Int, rr : Int) : Int{
		if(ll > rr) return -1
		if(ll == rr){
			if(ll == n){
				println("1 $n ${n-1}")
				System.out.flush()

				val s = f.readLine()
				if(s.equals("TAK")){
					return ll
				} else {
					return -1
				}
			} else {
				println("1 $ll ${ll+1}")
				System.out.flush()

				val s = f.readLine()
				if(s.equals("TAK")){
					return ll
				} else {
					return -1
				}
			}
		}

		var l = ll
		var r = rr
		var ans = -1
		while(l < r){
			val mid = l + (r-l)/2

			println("1 ${mid} ${mid+1}")
			System.out.flush()

			val s = f.readLine()

			if(s.equals("TAK")){
				//left
				ans = mid
				r = mid
			} else {
				ans = mid+1
				l = mid+1
			}
		}

		if(ans == ll && ans > 1){
			println("1 ${ans} ${ans-1}")
			System.out.flush()

			val s = f.readLine()

			if(s.equals("NIE")){
				return -1
			}
		} else if(ans == rr && ans < n){
			println("1 $ans ${ans+1}")
			System.out.flush()

			val s = f.readLine()

			if(s.equals("NIE")){
				return -1
			}
		}

		return ans
	}

	val a1 = find(1,n)

	val a2a = find(1,a1-1)
	val a2b = find(a1+1,n)

	if(a2a == -1) println("2 $a1 $a2b")
	else println("2 $a1 $a2a")

}


import java.io.*;
import java.util.*;

/*

8 3
NIE
TAK
NIE

 */

public class b {
	static Scanner in;

	public static void main(String[] args) throws IOException {
		in = new Scanner(System.in);
		int n = in.nextInt(), k = in.nextInt();
		int lo = 0, hi = n - 1;
		while (lo < hi) {
			int m1 = (lo + hi) / 2, m2 = m1 + 1;
			String res = query(m1, m2);
			if (res.equals("TAK")) {
				hi = m1;
			} else {
				lo = m2;
			}
		}
		int dish1 = lo;
		int leftCount = dish1;
		int rightCount = n - 1 - leftCount;
		System.out.println("found dish1=" + dish1);

		int dish2;
		int side;
		if(leftCount == 0) {
			side = 1;
		} else if(rightCount == 0) {
			side = 0;
		} else if (rightCount >= leftCount) {
			String tres = query(0, dish1 + leftCount-1);
			if (tres.equals("TAK")) {
				side = 0;
			} else {
				side = 1;
			}
		} else {
			String tres = query(n-1, dish1 - (rightCount-1));
			if (tres.equals("TAK")) {
				side = 1;
			} else {
				side = 0;
			}
		}
		System.out.println("side=" + side);
		if (side == 0) {
			// last one is from 0 to dish1-1
			lo = 0;
			hi = dish1 - 1;
			while (lo < hi) {
				int m1 = (lo + hi) / 2, m2 = m1 + 1;
				String res = query(m1, m2);
				if (res.equals("TAK")) {
					hi = m1;
				} else {
					lo = m2;
				}
			}
			dish2 = lo;
		} else {
			// last one is from dish1+1 to n-1
			lo = dish1+1;
			hi = n-1;
			while (lo < hi) {
				int m1 = (lo + hi) / 2, m2 = m1 + 1;
				String res = query(m2, m1);
				if (res.equals("NIE")) {
					hi = m1;
				} else {
					lo = m2;
				}
			}
			dish2 = lo;
		}
		System.out.println("2 " + (dish1+1) + " " + (dish2+1));
	}

	static String query(int a, int b) {
		System.out.print(1);
		System.out.print(' ');
		System.out.print(a + 1);
		System.out.print(' ');
		System.out.print(b + 1);
		System.out.println();
		System.out.flush();
		return in.next();
	}

	static class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(InputStream i) {
			br = new BufferedReader(new InputStreamReader(i));
			st = new StringTokenizer("");
		}

		public String next() throws IOException {
			if (st.hasMoreTokens())
				return st.nextToken();
			else
				st = new StringTokenizer(br.readLine());
			return next();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
	}
}


import java.io.*;
import java.util.*;

/*

8 3
NIE
TAK
NIE

 */

public class b {
	static Scanner in;

	public static void main(String[] args) throws IOException {
		in = new Scanner(System.in);
		int n = in.nextInt(), k = in.nextInt();
		int lo = 0, hi = n - 1;
		while (lo < hi) {
			int m1 = (lo + hi) / 2, m2 = m1 + 1;
			String res = query(m1, m2);
			if (res.equals("TAK")) {
				hi = m1;
			} else {
				lo = m2;
			}
		}
		int dish1 = lo;
		int leftCount = dish1;
		int rightCount = n - 1 - leftCount;
//		System.out.println("found dish1=" + dish1);

		int dish2;
		int side;
		if(leftCount == 0) {
			side = 1;
		} else if(rightCount == 0) {
			side = 0;
		} else if (rightCount >= leftCount) {
			String tres = query(0, dish1 + leftCount-1);
			if (tres.equals("TAK")) {
				side = 0;
			} else {
				side = 1;
			}
		} else {
			String tres = query(n-1, dish1 - (rightCount-1));
			if (tres.equals("TAK")) {
				side = 1;
			} else {
				side = 0;
			}
		}
//		System.out.println("side=" + side);
		if (side == 0) {
			// last one is from 0 to dish1-1
			lo = 0;
			hi = dish1 - 1;
			while (lo < hi) {
				int m1 = (lo + hi) / 2, m2 = m1 + 1;
				String res = query(m1, m2);
				if (res.equals("TAK")) {
					hi = m1;
				} else {
					lo = m2;
				}
			}
			dish2 = lo;
		} else {
			// last one is from dish1+1 to n-1
			lo = dish1+1;
			hi = n-1;
			while (lo < hi) {
				int m1 = (lo + hi) / 2, m2 = m1 + 1;
				String res = query(m2, m1);
				if (res.equals("NIE")) {
					hi = m1;
				} else {
					lo = m2;
				}
			}
			dish2 = lo;
		}
		System.out.println("2 " + (dish1+1) + " " + (dish2+1));
	}

	static String query(int a, int b) {
		System.out.print(1);
		System.out.print(' ');
		System.out.print(a + 1);
		System.out.print(' ');
		System.out.print(b + 1);
		System.out.println();
		System.out.flush();
		return in.next();
	}

	static class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(InputStream i) {
			br = new BufferedReader(new InputStreamReader(i));
			st = new StringTokenizer("");
		}

		public String next() throws IOException {
			if (st.hasMoreTokens())
				return st.nextToken();
			else
				st = new StringTokenizer(br.readLine());
			return next();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
	}
}


import java.io.*;
import java.util.*;

/*

8 3
NIE
TAK
NIE

 */

public class b {
	static Scanner in;

	public static void main(String[] args) throws IOException {
		in = new Scanner(System.in);
		int n = in.nextInt(), k = in.nextInt();
		int lo = 0, hi = n - 1;
		while (lo < hi) {
			int m1 = (lo + hi) / 2, m2 = m1 + 1;
			String res = query(m1, m2);
			if (res.equals("TAK")) {
				hi = m1;
			} else {
				lo = m2;
			}
		}
		int dish1 = lo;
		int leftCount = dish1;
		int rightCount = n - 1 - leftCount;
//		System.out.println("found dish1=" + dish1);

		int dish2;
		int side;
		if (rightCount >= leftCount) {
			String tres = query(0, dish1 + leftCount-1);
			if (tres.equals("TAK")) {
				side = 0;
			} else {
				side = 1;
			}
		} else {
			String tres = query(n-1, dish1 - (rightCount-1));
			if (tres.equals("TAK")) {
				side = 1;
			} else {
				side = 0;
			}
		}
//		System.out.println("side=" + side);
		if (side == 0) {
			// last one is from 0 to dish1-1
			lo = 0;
			hi = dish1 - 1;
			while (lo < hi) {
				int m1 = (lo + hi) / 2, m2 = m1 + 1;
				String res = query(m1, m2);
				if (res.equals("TAK")) {
					hi = m1;
				} else {
					lo = m2;
				}
			}
			dish2 = lo;
		} else {
			// last one is from dish1+1 to n-1
			lo = dish1+1;
			hi = n-1;
			while (lo < hi) {
				int m1 = (lo + hi) / 2, m2 = m1 + 1;
				String res = query(m2, m1);
				if (res.equals("NIE")) {
					hi = m1;
				} else {
					lo = m2;
				}
			}
			dish2 = lo;
		}
		System.out.println("2 " + (dish1+1) + " " + (dish2+1));
	}

	static String query(int a, int b) {
		System.out.print(1);
		System.out.print(' ');
		System.out.print(a + 1);
		System.out.print(' ');
		System.out.print(b + 1);
		System.out.println();
		System.out.flush();
		return in.next();
	}

	static class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(InputStream i) {
			br = new BufferedReader(new InputStreamReader(i));
			st = new StringTokenizer("");
		}

		public String next() throws IOException {
			if (st.hasMoreTokens())
				return st.nextToken();
			else
				st = new StringTokenizer(br.readLine());
			return next();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
	}
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.io.Closeable;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) throws Exception {
        Thread thread = new Thread(null, new TaskAdapter(), "", 1 << 27);
        thread.start();
        thread.join();
    }

    static class TaskAdapter implements Runnable {
        @Override
        public void run() {
            InputStream inputStream = System.in;
            OutputStream outputStream = System.out;
            FastInput in = new FastInput(inputStream);
            FastOutput out = new FastOutput(outputStream);
            BGladToSeeYou solver = new BGladToSeeYou();
            solver.solve(1, in, out);
            out.close();
        }
    }

    static class BGladToSeeYou {
        FastOutput out;
        FastInput in;

        public void solve(int testNumber, FastInput in, FastOutput out) {
            this.out = out;
            this.in = in;
            int n = in.readInt();
            int k = in.readInt();

            int x = binarySearch(1, n);
            if (x > 1) {
                int y = binarySearch(1, x - 1);
                if (ask(y, x) == 0) {
                    answer(x, y);
                    return;
                }
            }
            int y = binarySearch(x + 1, n);
            answer(x, y);
        }

        public int binarySearch(int l, int r) {
            while (l < r) {
                int m = (l + r) / 2;
                if (ask(m, m + 1) == 0) {
                    r = m;
                } else {
                    l = m + 1;
                }
            }
            return l;
        }

        public int ask(int x, int y) {
            out.printf("1 %d %d", x, y).println().flush();
            return in.readString().equals("TAK") ? 0 : 1;
        }

        public void answer(int x, int y) {
            out.printf("2 %d %d", x, y).println().flush();
        }

    }

    static class FastInput {
        private final InputStream is;
        private StringBuilder defaultStringBuf = new StringBuilder(1 << 13);
        private byte[] buf = new byte[1 << 13];
        private int bufLen;
        private int bufOffset;
        private int next;

        public FastInput(InputStream is) {
            this.is = is;
        }

        private int read() {
            while (bufLen == bufOffset) {
                bufOffset = 0;
                try {
                    bufLen = is.read(buf);
                } catch (IOException e) {
                    bufLen = -1;
                }
                if (bufLen == -1) {
                    return -1;
                }
            }
            return buf[bufOffset++];
        }

        public void skipBlank() {
            while (next >= 0 && next <= 32) {
                next = read();
            }
        }

        public int readInt() {
            int sign = 1;

            skipBlank();
            if (next == '+' || next == '-') {
                sign = next == '+' ? 1 : -1;
                next = read();
            }

            int val = 0;
            if (sign == 1) {
                while (next >= '0' && next <= '9') {
                    val = val * 10 + next - '0';
                    next = read();
                }
            } else {
                while (next >= '0' && next <= '9') {
                    val = val * 10 - next + '0';
                    next = read();
                }
            }

            return val;
        }

        public String readString(StringBuilder builder) {
            skipBlank();

            while (next > 32) {
                builder.append((char) next);
                next = read();
            }

            return builder.toString();
        }

        public String readString() {
            defaultStringBuf.setLength(0);
            return readString(defaultStringBuf);
        }

    }

    static class FastOutput implements AutoCloseable, Closeable, Appendable {
        private StringBuilder cache = new StringBuilder(10 << 20);
        private final Writer os;

        public FastOutput append(CharSequence csq) {
            cache.append(csq);
            return this;
        }

        public FastOutput append(CharSequence csq, int start, int end) {
            cache.append(csq, start, end);
            return this;
        }

        public FastOutput(Writer os) {
            this.os = os;
        }

        public FastOutput(OutputStream os) {
            this(new OutputStreamWriter(os));
        }

        public FastOutput append(char c) {
            cache.append(c);
            return this;
        }

        public FastOutput printf(String format, Object... args) {
            cache.append(String.format(format, args));
            return this;
        }

        public FastOutput println() {
            cache.append(System.lineSeparator());
            return this;
        }

        public FastOutput flush() {
            try {
                os.append(cache);
                os.flush();
                cache.setLength(0);
            } catch (IOException e) {
                throw new UncheckedIOException(e);
            }
            return this;
        }

        public void close() {
            flush();
            try {
                os.close();
            } catch (IOException e) {
                throw new UncheckedIOException(e);
            }
        }

        public String toString() {
            return cache.toString();
        }

    }
}


// practice with rainboy
import java.io.*;
import java.util.*;

public class CF809B extends PrintWriter {
	CF809B() { super(System.out, true); }
	Scanner sc = new Scanner(System.in);
	public static void main(String[] $) {
		CF809B o = new CF809B(); o.main(); o.flush();
	}

	boolean query(int i, int j) {
		println("1 " + i + " " + j);
		return sc.next().equals("TAK");
	}
	int search(int lower, int upper) {
		while (upper - lower > 1) {
			int i = (lower + upper) / 2;
			if (query(i, i + 1))
				upper = i;
			else
				lower = i;
		}
		return upper;
	}
	void main() {
		int n = sc.nextInt();
		int k = sc.nextInt();
		int i = search(0, n);
		int j = search(0, i - 1);
		if (j == 0 || !query(j, i))
			j = search(i, n);
		println("2 " + i + " " + j);
	}
}


// practice with rainboy
import java.io.*;
import java.util.*;

public class CF809B extends PrintWriter {
	CF809B() { super(System.out, true); }
	Scanner sc = new Scanner(System.in);
	public static void main(String[] $) {
		CF809B o = new CF809B(); o.main(); o.flush();
	}

	boolean query(int i, int j) {
		println("1 " + i + " " + j);
		return sc.next().equals("TAK");
	}
	int search(int lower, int upper) {
		while (upper - lower > 1) {
			int i = (lower + upper) / 2;
			if (query(i, i + 1))
				upper = i;
			else
				lower = i;
		}
		return upper;
	}
	int search_(int lower, int upper) {
		while (upper - lower > 1) {
			int i = (lower + upper) / 2;
			if (query(i + 1, i))
				lower = i;
			else
				upper = i;
		}
		return upper;
	}
	void main() {
		int n = sc.nextInt();
		int k = sc.nextInt();
		int i = search(0, n);
		int j = search(0, i - 1);
		if (j == 0 || !query(j, i))
			j = search_(i, n);
		println("2 " + i + " " + j);
	}
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        InputReader in;
        PrintWriter out;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            this.in = in;
            this.out = out;
            int n = in.nextInt(), k = in.nextInt();
            int pos = search(n, 0, n - 1);
            int other = search(n, 0, pos - 1);
            if (other == -1) {
                search(n, pos + 1, n - 1);
            }
            answer(pos, other);
        }

        private int search(int n, int left, int right) {
            if (right < left) {
                return -1;
            }
            int rightMost = left - 1;
            while (left <= right) {
                int mid = (left + right) / 2;
                if (ask(mid, mid + 1) == 1) {
                    rightMost = mid;
                    left = mid + 1;
                } else {
                    right = mid - 1;
                }
            }
            rightMost++;
            if (rightMost == n - 1 || ask(rightMost, rightMost + 1) == 0) {
                return rightMost;
            } else {
                return -1;
            }
        }

        private int ask(int x, int y) {
            out.println("1 " + (x + 1) + " " + (y + 1));
            out.flush();
            return in.next().equals("TAK") ? 0 : 1;
        }

        private void answer(int x, int y) {
            out.println("2 " + (x + 1) + " " + (y + 1));
            out.flush();
            System.exit(0);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new UnknownError();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new UnknownError();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public String next() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuffer res = new StringBuffer();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));

            return res.toString();
        }

        private boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }
}


#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for(int i = 0; i < (n); i++)
typedef long long tint;
const int N = 200050;

map<int, int> esta;
bool used[N];
int n, k, A[N], ans;

int main(){
    while( scanf("%d %d", &n, &k) == 2 ){
        forn(i, n){
            scanf("%d", &A[i]);
        }
        sort(A, A+n);
        forn(i, n){
            esta[ A[i] ] = i;
        }
        forn(i, n){
            if(used[i]) continue;
            used[i] = true;
            if( !esta.count(A[i] * k) ){
                //printf("Uso %d\n", A[i]);
                ans++;
                continue;
            }
            tint v = A[i] * k;
            int sz = 2;
            used[ i ] = true;
            used[ esta[A[i]*k] ] = true;
            //printf("EN LISTA: %d %d", A[i], v);
            while( esta.count(v * k) ){
                int p = esta[v * k];
                used[p] = true;
                v *= k;
                printf(" %d", v);
                sz++;
            }
            //printf("\nDe esta saque %d\n", (sz+1) / 2 );
            ans += (sz + 1) / 2;
        }
        esta.clear();
        printf("%d\n", ans);
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
struct l
{
    int b , g;
};
bool ss(l x , l y)
{
    if(x.b == y.b) return x.g < y.g ;
    else return x.b > y.b ;
}
int main()
{
    int n , m ;
    cin >> n >> m ;
    int a[n+1];
    for(int i = 0 ; i < n ; i++)cin >> a[i];
    sort(a,a+n);
    bool b[(int)1e6+5] ;
    int ans = 0 ;
    for(int i = n-1 ; i >= 0 ; i--)
    {
        int x = a[i]*m ;
        int s = 0 , e = n-1 , r = -1;
        while(s<=e)
        {
            int mid = s+(e-s)/2 ;
            if(a[mid] == x)
            {
                r = mid ;
                break ;
            }
            else if (a[mid] < x) s = mid+1 ;
            else e = mid-1 ;
        }
        if(r == -1)ans++ , b[i] = 1;
        else if(!b[r])ans++ , b[i] = 1 ;
    }
    cout << ans << endl ;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
struct l
{
    int b , g;
};
bool ss(l x , l y)
{
    if(x.b == y.b) return x.g < y.g ;
    else return x.b > y.b ;
}
int main()
{
    int n , m ;
    cin >> n >> m ;
    int a[n+1];
    for(int i = 0 ; i < n ; i++)cin >> a[i];
    sort(a,a+n);
    bool b[(int)1e6+5] ;
    int ans = 0 ;
    for(int i = n-1 ; i >= 0 ; i--)
    {
        long long x = a[i]*m ;
        long long s = 0 , e = n-1 , r = -1;
        while(s<=e)
        {
            int mid = s+(e-s)/2 ;
            if(a[mid] == x)
            {
                r = mid ;
                break ;
            }
            else if (a[mid] < x) s = mid+1 ;
            else e = mid-1 ;
        }
        if(r == -1)ans++ , b[i] = 1;
        else if(!b[r])ans++ , b[i] = 1 ;
    }
    cout << ans << endl ;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
struct l
{
    int b , g;
};
bool ss(l x , l y)
{
    if(x.b == y.b) return x.g < y.g ;
    else return x.b > y.b ;
}
bool b[(int)1e6+5] ;
int main()
{
    int n , m ;
    cin >> n >> m ;
    int a[n+1];
    for(int i = 0 ; i < n ; i++)cin >> a[i];
    sort(a,a+n);
    int ans = 0 ;
    for(int i = 0 ; i < n ; i++)
    {
        if(b[i])continue;
        long long x = a[i]*m ;
        long long s = 0 , e = n-1 , r = -1;
        while(s<=e)
        {
            int mid = s+(e-s)/2 ;
            if(a[mid] == x)
            {
                r = mid ;
                break ;
            }
            else if (a[mid] < x) s = mid+1 ;
            else e = mid-1 ;
        }
        if(r == -1) ans++ ;
        else ans++ , b[r] = 1 ;
    }
    cout << ans << endl ;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
struct l
{
    int b , g;
};
bool ss(l x , l y)
{
    if(x.b == y.b) return x.g < y.g ;
    else return x.b > y.b ;
}
int main()
{
    int n , m ;
    cin >> n >> m ;
    int a[n+1];
    for(int i = 0 ; i < n ; i++)cin >> a[i];
    sort(a,a+n);
    int ans = 0 ;
    for(int i = n-1 ; i >= 0 ; i--)
    {
        int x = a[i]*m ;
        int s = 0 , e = n-1 , r = -1;
        while(s<=e)
        {
            int mid = s+(e-s)/2 ;
            if(a[mid] == x)
            {
                r = mid ;
                break ;
            }
            else if (a[mid] < x) s = mid+1 ;
            else e = mid-1 ;
        }
        if(r != -1)ans++ ;
    }
    cout << ans << endl ;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
struct l
{
    int b , g;
};
bool ss(l x , l y)
{
    if(x.b == y.b) return x.g < y.g ;
    else return x.b > y.b ;
}
int main()
{
    int n , m ;
    cin >> n >> m ;
    int a[n+1];
    for(int i = 0 ; i < n ; i++)cin >> a[i];
    sort(a,a+n);
    bool b[(int)1e6+5] ;
    int ans = 0 ;
    for(int i = 0 ; i < n ; i++)
    {
        if(b[i])continue;
        long long x = a[i]*m ;
        long long s = 0 , e = n-1 , r = -1;
        while(s<=e)
        {
            int mid = s+(e-s)/2 ;
            if(a[mid] == x)
            {
                r = mid ;
                break ;
            }
            else if (a[mid] < x) s = mid+1 ;
            else e = mid-1 ;
        }
        if(r == -1) ans++ ;
        else ans++ , b[r] = 1 ;
    }
    cout << ans << endl ;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
struct l
{
    int b , g;
};
bool ss(l x , l y)
{
    if(x.b == y.b) return x.g < y.g ;
    else return x.b > y.b ;
}
int main()
{
    int n , m ;
    cin >> n >> m ;
    int a[n+1];
    for(int i = 0 ; i < n ; i++)cin >> a[i];
    sort(a,a+n);
    int ans = 0 ;
    for(int i = 0 ; i < n ; i++)
    {
        if(a[i]%m) continue;
        else
        {
            int x = a[i]/m ;
            int s = 0 , e = n-1 , r = -1;
            while(s<=e)
            {
                int mid = s+(e-s)/2 ;
                if(a[mid] == x)
                {
                    r = mid ;
                    break ;
                }
                else if (a[mid] < x) s = mid+1 ;
                else e = mid-1 ;
            }
            if(r != -1)ans++ ;
        }
    }
    cout << ans << endl ;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
struct l
{
    int b , g;
};
bool ss(l x , l y)
{
    if(x.b == y.b) return x.g < y.g ;
    else return x.b > y.b ;
}
bool b[(int)1e6+5] ;
int main()
{
    int n , m ;
    cin >> n >> m ;
    long long a[n+1];
    for(int i = 0 ; i < n ; i++)cin >> a[i];
    sort(a,a+n);
    int ans = 0 ;
    for(int i = 0 ; i < n ; i++)
    {
        if(b[i])continue;
        long long x = a[i]*m ;
        long long s = 0 , e = n-1 , r = -1;
        while(s<=e)
        {
            int mid = s+(e-s)/2 ;
            if(a[mid] == x)
            {
                r = mid ;
                break ;
            }
            else if (a[mid] < x) s = mid+1 ;
            else e = mid-1 ;
        }
        if(r == -1) ans++ ;
        else ans++ , b[r] = 1 ;
    }
    cout << ans << endl ;
    return 0;
}


#include <cmath>
#include <ctime>
#include <iostream>
#include <string>
#include <vector>
#include<cstdio>
#include<sstream>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<cctype>
#include <iomanip>
#include <string>
#include <sstream>
#include <functional>
#include <numeric>
#include <stack>
#include <climits>
#include <float.h>
#include<unordered_map>
#include <bitset>

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define f(i,a,b) for(int i=a;i<b;i++)
#define F(i,a,b) for(int i=a;i>=    b;i--)
#define sz(a) ((int)a.size())
#define all(c) c.begin(), c.end()
#define fast ios_base::sync_with_stdio(0);cin.tie(0);
#define dbgs(x) cerr << (#x) << " --> " << (x) << ' '
#define dbg(x) cerr << (#x) << " --> " << (x) << endl
#define sz(a) ((int)a.size())

typedef long long ll;
typedef unsigned long long ull;
typedef pair <ll, ll> pll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pair<int, int> > vpii;
typedef map<int, int> mii;
typedef map<ll, ll> mll;
typedef pair<int, int> pii;
typedef pair<string, int> psi;
typedef long double ld;

template <class T> const T& max(const T& a, const T&b, const T&c) { return max(a, max(b, c)); }

template <class T> const T& min(const T& a, const T&b, const T&c) { return min(a, min(b, c)); }

void sc(int &a) { scanf("%d", &a); }void sc(ll &a) { scanf("%lld", &a); }void sc(int& a, int& b) { sc(a); sc(b); }
void sc(ll &a, ll &b) { sc(a); sc(b); }void sc(int& a, int& b, int& c) { sc(a, b); sc(c); }void sc(ll& a, ll& b, ll& c) { sc(a, b); sc(c); }
void prl(int a) { printf("%d\n", a); }void prl(ll a) { printf("%lld\n", a); }void prl() { printf("\n"); }
void prs(int a) { printf("%d ", a); }void prs(ll a) { printf("%lld ", a); }

ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }

ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); }

ll poww(ll a, ll b) {

	if (b == 0) return 1;

	ll tmp = poww(a, b / 2);

	return (b & 1 ? a * tmp * tmp : tmp * tmp);

}

ll sumOfDigs(string s) { ll sum = 0; for (int i = 0; i < s.length(); i++) sum += s[i] - '0'; return sum; }

ll sumOfDigs(ll n) { return (n < 10 ? n : n % 10 + sumOfDigs(n / 10)); }

string itos(ll i) { string s = ""; 	while (i) { s += char(i % 10 + '0'); i /= 10; } reverse(all(s));  return s; }

ll stoi(string &s) { ll tot = 0; for (int i = (int)s.length() - 1, j = 1; i >= 0; i--, j *= 10) { tot += j * (s[i] + '0'); }  return tot; }

int months[13] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };

using namespace std;

#define PI acos((ld)-1.0)

void tt() {

#ifndef online	_judge
	freopen("test.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

#endif
}

// printf("%.8lf\n", sum * 1.0 / n);  // precision setting

ll mod = 1000000000000000003;

ll modpower(ll x, ll y, ll p)
{

	x %= mod;

	if (!y) return 1;

	ll res = 1;

	if (y & 1) { res *= x;  res %= p; }

	ll z = modpower(x, y / 2, p);

	z %= p;

	z *= z;

	z %= mod;

	res *= z;

	res %= p;

	return res;

}

int main() {

	//tt();
	set<int> s;

	ll n, k;
	cin >> n >> k;

	for (int i = 1; i <= n; i++) {

		int x;
		cin >> x;
		s.insert(x);
	}

	for (auto itr = s.begin(); itr != s.end(); ++itr) {

		ll curr = *itr;
		curr *= k;
		if (s.find(curr) != s.end()) { s.erase(s.find(curr)); }

		if ((int)s.size() == 0) break;

	}

	cout << (int)s.size() << endl;

	return 0;

}


#include <cmath>
#include <ctime>
#include <iostream>
#include <string>
#include <vector>
#include<cstdio>
#include<sstream>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<cctype>
#include <iomanip>
#include <string>
#include <sstream>
#include <functional>
#include <numeric>
#include <stack>
#include <climits>
#include <float.h>
#include<unordered_map>
#include <bitset>

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define f(i,a,b) for(int i=a;i<b;i++)
#define F(i,a,b) for(int i=a;i>=    b;i--)
#define sz(a) ((int)a.size())
#define all(c) c.begin(), c.end()
#define fast ios_base::sync_with_stdio(0);cin.tie(0);
#define dbgs(x) cerr << (#x) << " --> " << (x) << ' '
#define dbg(x) cerr << (#x) << " --> " << (x) << endl
#define sz(a) ((int)a.size())

typedef long long ll;
typedef unsigned long long ull;
typedef pair <ll, ll> pll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pair<int, int> > vpii;
typedef map<int, int> mii;
typedef map<ll, ll> mll;
typedef pair<int, int> pii;
typedef pair<string, int> psi;
typedef long double ld;

template <class T> const T& max(const T& a, const T&b, const T&c) { return max(a, max(b, c)); }

template <class T> const T& min(const T& a, const T&b, const T&c) { return min(a, min(b, c)); }

void sc(int &a) { scanf("%d", &a); }void sc(ll &a) { scanf("%lld", &a); }void sc(int& a, int& b) { sc(a); sc(b); }
void sc(ll &a, ll &b) { sc(a); sc(b); }void sc(int& a, int& b, int& c) { sc(a, b); sc(c); }void sc(ll& a, ll& b, ll& c) { sc(a, b); sc(c); }
void prl(int a) { printf("%d\n", a); }void prl(ll a) { printf("%lld\n", a); }void prl() { printf("\n"); }
void prs(int a) { printf("%d ", a); }void prs(ll a) { printf("%lld ", a); }

ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }

ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); }

ll poww(ll a, ll b) {

	if (b == 0) return 1;

	ll tmp = poww(a, b / 2);

	return (b & 1 ? a * tmp * tmp : tmp * tmp);

}

ll sumOfDigs(string s) { ll sum = 0; for (int i = 0; i < s.length(); i++) sum += s[i] - '0'; return sum; }

ll sumOfDigs(ll n) { return (n < 10 ? n : n % 10 + sumOfDigs(n / 10)); }

string itos(ll i) { string s = ""; 	while (i) { s += char(i % 10 + '0'); i /= 10; } reverse(all(s));  return s; }

ll stoi(string &s) { ll tot = 0; for (int i = (int)s.length() - 1, j = 1; i >= 0; i--, j *= 10) { tot += j * (s[i] + '0'); }  return tot; }

int months[13] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };

using namespace std;

#define PI acos((ld)-1.0)

void tt() {

#ifndef online	_judge
	freopen("test.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

#endif
}

// printf("%.8lf\n", sum * 1.0 / n);  // precision setting

ll mod = 1000000000000000003;

ll modpower(ll x, ll y, ll p)
{

	x %= mod;

	if (!y) return 1;

	ll res = 1;

	if (y & 1) { res *= x;  res %= p; }

	ll z = modpower(x, y / 2, p);

	z %= p;

	z *= z;

	z %= mod;

	res *= z;

	res %= p;

	return res;

}

int main() {

	//tt();
	set<ll> s;

	ll n, k;
	cin >> n >> k;

	for (int i = 1; i <= n; i++) {

		int x;
		cin >> x;
		s.insert(x);

	}

	for (auto itr = s.begin(); itr != s.end(); ++itr) {

		ll curr = *itr;

		curr *= k;

		if (s.find(curr) != s.end()) { s.erase(s.find(curr)); }

	}

	cout << (int)s.size() << endl;

	return 0;

}


#include <cmath>
#include <ctime>
#include <iostream>
#include <string>
#include <vector>
#include<cstdio>
#include<sstream>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<cctype>
#include <iomanip>
#include <string>
#include <sstream>
#include <functional>
#include <numeric>
#include <stack>
#include <climits>
#include <float.h>
#include<unordered_map>
#include <bitset>

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define f(i,a,b) for(int i=a;i<b;i++)
#define F(i,a,b) for(int i=a;i>=    b;i--)
#define sz(a) ((int)a.size())
#define all(c) c.begin(), c.end()
#define fast ios_base::sync_with_stdio(0);cin.tie(0);
#define dbgs(x) cerr << (#x) << " --> " << (x) << ' '
#define dbg(x) cerr << (#x) << " --> " << (x) << endl
#define sz(a) ((int)a.size())

typedef long long ll;
typedef unsigned long long ull;
typedef pair <ll, ll> pll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pair<int, int> > vpii;
typedef map<int, int> mii;
typedef map<ll, ll> mll;
typedef pair<int, int> pii;
typedef pair<string, int> psi;
typedef long double ld;

template <class T> const T& max(const T& a, const T&b, const T&c) { return max(a, max(b, c)); }

template <class T> const T& min(const T& a, const T&b, const T&c) { return min(a, min(b, c)); }

void sc(int &a) { scanf("%d", &a); }void sc(ll &a) { scanf("%lld", &a); }void sc(int& a, int& b) { sc(a); sc(b); }
void sc(ll &a, ll &b) { sc(a); sc(b); }void sc(int& a, int& b, int& c) { sc(a, b); sc(c); }void sc(ll& a, ll& b, ll& c) { sc(a, b); sc(c); }
void prl(int a) { printf("%d\n", a); }void prl(ll a) { printf("%lld\n", a); }void prl() { printf("\n"); }
void prs(int a) { printf("%d ", a); }void prs(ll a) { printf("%lld ", a); }

ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }

ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); }

ll poww(ll a, ll b) {

	if (b == 0) return 1;

	ll tmp = poww(a, b / 2);

	return (b & 1 ? a * tmp * tmp : tmp * tmp);

}

ll sumOfDigs(string s) { ll sum = 0; for (int i = 0; i < s.length(); i++) sum += s[i] - '0'; return sum; }

ll sumOfDigs(ll n) { return (n < 10 ? n : n % 10 + sumOfDigs(n / 10)); }

string itos(ll i) { string s = ""; 	while (i) { s += char(i % 10 + '0'); i /= 10; } reverse(all(s));  return s; }

ll stoi(string &s) { ll tot = 0; for (int i = (int)s.length() - 1, j = 1; i >= 0; i--, j *= 10) { tot += j * (s[i] + '0'); }  return tot; }

int months[13] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };

using namespace std;

#define PI acos((ld)-1.0)

void tt() {

#ifndef online	_judge
	freopen("test.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

#endif
}

// printf("%.8lf\n", sum * 1.0 / n);  // precision setting

ll mod = 1000000000000000003;

ll modpower(ll x, ll y, ll p)
{

	x %= mod;

	if (!y) return 1;

	ll res = 1;

	if (y & 1) { res *= x;  res %= p; }

	ll z = modpower(x, y / 2, p);

	z %= p;

	z *= z;

	z %= mod;

	res *= z;

	res %= p;

	return res;

}

int main() {

	//tt();
	set<ll> s, w;

	ll n, k;
	cin >> n >> k;

	for (int i = 1; i <= n; i++) {

		int x;
		cin >> x;
		s.insert(x);
		w.insert(x);
	}

	for (auto itr = s.begin(); itr != s.end(); ++itr) {

		ll curr = *itr;

		curr *= k;

		if (w.find(curr) != w.end()) { w.erase(w.find(curr)); }

	}

	cout << (int)w.size() << endl;

	return 0;

}


#include <cmath>
#include <ctime>
#include <iostream>
#include <string>
#include <vector>
#include<cstdio>
#include<sstream>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<cctype>
#include <iomanip>
#include <string>
#include <sstream>
#include <functional>
#include <numeric>
#include <stack>
#include <climits>
#include <float.h>
#include<unordered_map>
#include <bitset>

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define f(i,a,b) for(int i=a;i<b;i++)
#define F(i,a,b) for(int i=a;i>=    b;i--)
#define sz(a) ((int)a.size())
#define all(c) c.begin(), c.end()
#define fast ios_base::sync_with_stdio(0);cin.tie(0);
#define dbgs(x) cerr << (#x) << " --> " << (x) << ' '
#define dbg(x) cerr << (#x) << " --> " << (x) << endl
#define sz(a) ((int)a.size())

typedef long long ll;
typedef unsigned long long ull;
typedef pair <ll, ll> pll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pair<int, int> > vpii;
typedef map<int, int> mii;
typedef map<ll, ll> mll;
typedef pair<int, int> pii;
typedef pair<string, int> psi;
typedef long double ld;

template <class T> const T& max(const T& a, const T&b, const T&c) { return max(a, max(b, c)); }

template <class T> const T& min(const T& a, const T&b, const T&c) { return min(a, min(b, c)); }

void sc(int &a) { scanf("%d", &a); }void sc(ll &a) { scanf("%lld", &a); }void sc(int& a, int& b) { sc(a); sc(b); }
void sc(ll &a, ll &b) { sc(a); sc(b); }void sc(int& a, int& b, int& c) { sc(a, b); sc(c); }void sc(ll& a, ll& b, ll& c) { sc(a, b); sc(c); }
void prl(int a) { printf("%d\n", a); }void prl(ll a) { printf("%lld\n", a); }void prl() { printf("\n"); }
void prs(int a) { printf("%d ", a); }void prs(ll a) { printf("%lld ", a); }

ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }

ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); }

ll poww(ll a, ll b) {

	if (b == 0) return 1;

	ll tmp = poww(a, b / 2);

	return (b & 1 ? a * tmp * tmp : tmp * tmp);

}

ll sumOfDigs(string s) { ll sum = 0; for (int i = 0; i < s.length(); i++) sum += s[i] - '0'; return sum; }

ll sumOfDigs(ll n) { return (n < 10 ? n : n % 10 + sumOfDigs(n / 10)); }

string itos(ll i) { string s = ""; 	while (i) { s += char(i % 10 + '0'); i /= 10; } reverse(all(s));  return s; }

ll stoi(string &s) { ll tot = 0; for (int i = (int)s.length() - 1, j = 1; i >= 0; i--, j *= 10) { tot += j * (s[i] + '0'); }  return tot; }

int months[13] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };

using namespace std;

#define PI acos((ld)-1.0)

void tt() {

#ifndef online	_judge
	freopen("test.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

#endif
}

// printf("%.8lf\n", sum * 1.0 / n);  // precision setting

ll mod = 1000000000000000003;

ll modpower(ll x, ll y, ll p)
{

	x %= mod;

	if (!y) return 1;

	ll res = 1;

	if (y & 1) { res *= x;  res %= p; }

	ll z = modpower(x, y / 2, p);

	z %= p;

	z *= z;

	z %= mod;

	res *= z;

	res %= p;

	return res;

}

int main() {

	//tt();
	set<ll> s;

	ll n, k;
	cin >> n >> k;

	for (int i = 1; i <= n; i++) {

		int x;
		cin >> x;
		s.insert(x);

	}

	for (auto itr = s.begin(); itr != s.end(); ++itr) {

		ll curr = *itr;

		while (curr <= *s.rbegin()) {

			curr *= k;

			if (s.find(curr) != s.end()) { s.erase(s.find(curr));  }

		}

	}

	cout << (int)s.size() << endl;

	return 0;

}


#include <cmath>
#include <ctime>
#include <iostream>
#include <string>
#include <vector>
#include<cstdio>
#include<sstream>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<cctype>
#include <iomanip>
#include <string>
#include <sstream>
#include <functional>
#include <numeric>
#include <stack>
#include <climits>
#include <float.h>
#include<unordered_map>
#include <bitset>

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define f(i,a,b) for(int i=a;i<b;i++)
#define F(i,a,b) for(int i=a;i>=    b;i--)
#define sz(a) ((int)a.size())
#define all(c) c.begin(), c.end()
#define fast ios_base::sync_with_stdio(0);cin.tie(0);
#define dbgs(x) cerr << (#x) << " --> " << (x) << ' '
#define dbg(x) cerr << (#x) << " --> " << (x) << endl
#define sz(a) ((int)a.size())

typedef long long ll;
typedef unsigned long long ull;
typedef pair <ll, ll> pll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pair<int, int> > vpii;
typedef map<int, int> mii;
typedef map<ll, ll> mll;
typedef pair<int, int> pii;
typedef pair<string, int> psi;
typedef long double ld;

template <class T> const T& max(const T& a, const T&b, const T&c) { return max(a, max(b, c)); }

template <class T> const T& min(const T& a, const T&b, const T&c) { return min(a, min(b, c)); }

void sc(int &a) { scanf("%d", &a); }void sc(ll &a) { scanf("%lld", &a); }void sc(int& a, int& b) { sc(a); sc(b); }
void sc(ll &a, ll &b) { sc(a); sc(b); }void sc(int& a, int& b, int& c) { sc(a, b); sc(c); }void sc(ll& a, ll& b, ll& c) { sc(a, b); sc(c); }
void prl(int a) { printf("%d\n", a); }void prl(ll a) { printf("%lld\n", a); }void prl() { printf("\n"); }
void prs(int a) { printf("%d ", a); }void prs(ll a) { printf("%lld ", a); }

ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }

ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); }

ll poww(ll a, ll b) {

	if (b == 0) return 1;

	ll tmp = poww(a, b / 2);

	return (b & 1 ? a * tmp * tmp : tmp * tmp);

}

ll sumOfDigs(string s) { ll sum = 0; for (int i = 0; i < s.length(); i++) sum += s[i] - '0'; return sum; }

ll sumOfDigs(ll n) { return (n < 10 ? n : n % 10 + sumOfDigs(n / 10)); }

string itos(ll i) { string s = ""; 	while (i) { s += char(i % 10 + '0'); i /= 10; } reverse(all(s));  return s; }

ll stoi(string &s) { ll tot = 0; for (int i = (int)s.length() - 1, j = 1; i >= 0; i--, j *= 10) { tot += j * (s[i] + '0'); }  return tot; }

int months[13] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };

using namespace std;

#define PI acos((ld)-1.0)

void tt() {

#ifndef online	_judge
	freopen("test.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

#endif
}

// printf("%.8lf\n", sum * 1.0 / n);  // precision setting

ll mod = 1000000000000000003;

ll modpower(ll x, ll y, ll p)
{

	x %= mod;

	if (!y) return 1;

	ll res = 1;

	if (y & 1) { res *= x;  res %= p; }

	ll z = modpower(x, y / 2, p);

	z %= p;

	z *= z;

	z %= mod;

	res *= z;

	res %= p;

	return res;

}

int main() {

	//tt();
	set<ll> s;

	ll n, k;
	cin >> n >> k;

	for (int i = 1; i <= n; i++) {

		int x;
		cin >> x;
		s.insert(x);

	}

	for (auto itr = s.begin(); itr != s.end(); ++itr) {

		if (k == 1) continue;

		ll curr = *itr;

		curr *= k;

		if (s.find(curr) != s.end()) { s.erase(s.find(curr)); }

	}

	cout << (int)s.size() << endl;

	return 0;

}


#include <cmath>
#include <ctime>
#include <iostream>
#include <string>
#include <vector>
#include<cstdio>
#include<sstream>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<cctype>
#include <iomanip>
#include <string>
#include <sstream>
#include <functional>
#include <numeric>
#include <stack>
#include <climits>
#include <float.h>
#include<unordered_map>
#include <bitset>

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define f(i,a,b) for(int i=a;i<b;i++)
#define F(i,a,b) for(int i=a;i>=    b;i--)
#define sz(a) ((int)a.size())
#define all(c) c.begin(), c.end()
#define fast ios_base::sync_with_stdio(0);cin.tie(0);
#define dbgs(x) cerr << (#x) << " --> " << (x) << ' '
#define dbg(x) cerr << (#x) << " --> " << (x) << endl
#define sz(a) ((int)a.size())

typedef long long ll;
typedef unsigned long long ull;
typedef pair <ll, ll> pll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pair<int, int> > vpii;
typedef map<int, int> mii;
typedef map<ll, ll> mll;
typedef pair<int, int> pii;
typedef pair<string, int> psi;
typedef long double ld;

template <class T> const T& max(const T& a, const T&b, const T&c) { return max(a, max(b, c)); }

template <class T> const T& min(const T& a, const T&b, const T&c) { return min(a, min(b, c)); }

void sc(int &a) { scanf("%d", &a); }void sc(ll &a) { scanf("%lld", &a); }void sc(int& a, int& b) { sc(a); sc(b); }
void sc(ll &a, ll &b) { sc(a); sc(b); }void sc(int& a, int& b, int& c) { sc(a, b); sc(c); }void sc(ll& a, ll& b, ll& c) { sc(a, b); sc(c); }
void prl(int a) { printf("%d\n", a); }void prl(ll a) { printf("%lld\n", a); }void prl() { printf("\n"); }
void prs(int a) { printf("%d ", a); }void prs(ll a) { printf("%lld ", a); }

ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }

ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); }

ll poww(ll a, ll b) {

	if (b == 0) return 1;

	ll tmp = poww(a, b / 2);

	return (b & 1 ? a * tmp * tmp : tmp * tmp);

}

ll sumOfDigs(string s) { ll sum = 0; for (int i = 0; i < s.length(); i++) sum += s[i] - '0'; return sum; }

ll sumOfDigs(ll n) { return (n < 10 ? n : n % 10 + sumOfDigs(n / 10)); }

string itos(ll i) { string s = ""; 	while (i) { s += char(i % 10 + '0'); i /= 10; } reverse(all(s));  return s; }

ll stoi(string &s) { ll tot = 0; for (int i = (int)s.length() - 1, j = 1; i >= 0; i--, j *= 10) { tot += j * (s[i] + '0'); }  return tot; }

int months[13] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };

using namespace std;

#define PI acos((ld)-1.0)

void tt() {

#ifndef online	_judge
	freopen("test.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

#endif
}

// printf("%.8lf\n", sum * 1.0 / n);  // precision setting

ll mod = 1000000000000000003;

ll modpower(ll x, ll y, ll p)
{

	x %= mod;

	if (!y) return 1;

	ll res = 1;

	if (y & 1) { res *= x;  res %= p; }

	ll z = modpower(x, y / 2, p);

	z %= p;

	z *= z;

	z %= mod;

	res *= z;

	res %= p;

	return res;

}

int main() {

	//tt();
	set<ll> s;

	ll n, k;
	cin >> n >> k;

	for (int i = 1; i <= n; i++) {

		int x;
		cin >> x;
		s.insert(x);

	}

	for (auto itr = s.begin(); itr != s.end(); ++itr) {

		ll curr = *itr;

		curr *= k;

		auto pos = s.find(curr);

		if (pos != itr) { s.erase(pos); }

		if (s.size() == 0) break;
	}

	cout << (int)s.size() << endl;

	return 0;

}


#include <cmath>
#include <ctime>
#include <iostream>
#include <string>
#include <vector>
#include<cstdio>
#include<sstream>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<cctype>
#include <iomanip>
#include <string>
#include <sstream>
#include <functional>
#include <numeric>
#include <stack>
#include <climits>
#include <float.h>
#include<unordered_map>
#include <bitset>

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define f(i,a,b) for(int i=a;i<b;i++)
#define F(i,a,b) for(int i=a;i>=    b;i--)
#define sz(a) ((int)a.size())
#define all(c) c.begin(), c.end()
#define fast ios_base::sync_with_stdio(0);cin.tie(0);
#define dbgs(x) cerr << (#x) << " --> " << (x) << ' '
#define dbg(x) cerr << (#x) << " --> " << (x) << endl
#define sz(a) ((int)a.size())

typedef long long ll;
typedef unsigned long long ull;
typedef pair <ll, ll> pll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pair<int, int> > vpii;
typedef map<int, int> mii;
typedef map<ll, ll> mll;
typedef pair<int, int> pii;
typedef pair<string, int> psi;
typedef long double ld;

template <class T> const T& max(const T& a, const T&b, const T&c) { return max(a, max(b, c)); }

template <class T> const T& min(const T& a, const T&b, const T&c) { return min(a, min(b, c)); }

void sc(int &a) { scanf("%d", &a); }void sc(ll &a) { scanf("%lld", &a); }void sc(int& a, int& b) { sc(a); sc(b); }
void sc(ll &a, ll &b) { sc(a); sc(b); }void sc(int& a, int& b, int& c) { sc(a, b); sc(c); }void sc(ll& a, ll& b, ll& c) { sc(a, b); sc(c); }
void prl(int a) { printf("%d\n", a); }void prl(ll a) { printf("%lld\n", a); }void prl() { printf("\n"); }
void prs(int a) { printf("%d ", a); }void prs(ll a) { printf("%lld ", a); }

ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }

ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); }

ll poww(ll a, ll b) {

	if (b == 0) return 1;

	ll tmp = poww(a, b / 2);

	return (b & 1 ? a * tmp * tmp : tmp * tmp);

}

ll sumOfDigs(string s) { ll sum = 0; for (int i = 0; i < s.length(); i++) sum += s[i] - '0'; return sum; }

ll sumOfDigs(ll n) { return (n < 10 ? n : n % 10 + sumOfDigs(n / 10)); }

string itos(ll i) { string s = ""; 	while (i) { s += char(i % 10 + '0'); i /= 10; } reverse(all(s));  return s; }

ll stoi(string &s) { ll tot = 0; for (int i = (int)s.length() - 1, j = 1; i >= 0; i--, j *= 10) { tot += j * (s[i] + '0'); }  return tot; }

int months[13] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };

using namespace std;

#define PI acos((ld)-1.0)

void tt() {

#ifndef online	_judge
	freopen("test.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

#endif
}

// printf("%.8lf\n", sum * 1.0 / n);  // precision setting

ll mod = 1000000000000000003;

ll modpower(ll x, ll y, ll p)
{

	x %= mod;

	if (!y) return 1;

	ll res = 1;

	if (y & 1) { res *= x;  res %= p; }

	ll z = modpower(x, y / 2, p);

	z %= p;

	z *= z;

	z %= mod;

	res *= z;

	res %= p;

	return res;

}

int main() {

	//tt();
	set<ll> s;

	ll n, k;
	cin >> n >> k;

	for (int i = 1; i <= n; i++) {

		int x;
		cin >> x;
		s.insert(x);

	}

	for (auto itr = s.begin(); itr != s.end(); ++itr) {

		ll curr = *itr;

		curr *= k;

		if (s.find(curr) != s.end()) { s.erase(s.find(curr)); }

		if (s.size() == 0) break;
	}

	cout << (int)s.size() << endl;

	return 0;

}


#include<bits/stdc++.h>
using namespace std;
#define all(v) v.begin(),v.end()
#define V vector
#define S string
#define pb push_back
#define sz size()
#define get cin>>
#define print cout<<
typedef long long ll;
typedef unsigned long long ull;
int main(){
	cin.tie(0);
	std::ios::sync_with_stdio(false);
	ll n, k; get n >> k;
	V<ll> v(n); V<bool> isExist(1000000000+1,0);
	for (int i = 0; i<n; i++){ get v[i]; isExist[v[i]] = 1; }
	sort(all(v)); int ans=v.sz;
	if(v.sz==1){cout<<1; return 0;}
	for (int i = 0; i<v.sz; i++){
		if (v[i] * k<=1000000000&&isExist[v[i] * k]){
            isExist[v[i] * k]=0;
			ans--;
		}
	}
	print ans;
}


#include<bits/stdc++.h>
using namespace std;
#define all(v) v.begin(),v.end()
#define V vector
#define S string
#define pb push_back
#define sz size()
#define get cin>>
#define print cout<<
typedef long long ll;
typedef unsigned long long ull;
int main(){
    cin.tie(0);
    std::ios::sync_with_stdio(false);
    ll n, k; get n >> k;
    V<ll> v(n); V<bool> isExist(1000000000+1,0);
    for (int i = 0; i<n; i++){ get v[i]; isExist[v[i]] = 1; }
    sort(all(v));
    if(v.sz==1){cout<<1; return 0;}
    for (int i = 0; i<v.sz; i++){
        if (v[i] * k<=1000000000&&isExist[v[i] * k]&&!v.empty()){
            isExist[v[i] * k]=0;
            v.erase(find(v.begin(), v.end(), v[i] * k));
            i--;
        }
    }
    print v.sz;
}


#include<bits/stdc++.h>
using namespace std;
#define all(v) v.begin(),v.end()
#define V vector
#define S string
#define pb push_back
#define sz size()
#define get cin>>
#define print cout<<
typedef long long ll;
typedef unsigned long long ull;
int main(){
    cin.tie(0);
    std::ios::sync_with_stdio(false);
    int isExist[100000+1]={0};
    int n,k; get n>>k; int ar[n];
    for(int i=0;i<n;i++){get ar[i]; isExist[ar[i]]=1;}
    int ans=0;
    for(int i=0;i<n;i++){
        if(!isExist[ar[i]*k])ans++;
    }
    print ans;
}


#include<bits/stdc++.h>
using namespace std;
#define all(v) v.begin(),v.end()
#define V vector
#define S string
#define pb push_back
#define sz size()
#define get cin>>
#define print cout<<
typedef long long ll;
typedef unsigned long long ull;
int main(){
    cin.tie(0);
    std::ios::sync_with_stdio(false);
    ll n, k; get n >> k;
    int v[n]; V<bool> isExist(1000000000+1,false);
    for (int i = 0; i<n; i++){ get v[i]; isExist[v[i]] = true; }
    sort(v,v+n); int ans=n;
    if(n==1){cout<<1; return 0;}
    if(k==1){cout<<n; return 0;}
    for (int i = 0; i<n; i++){
        if (v[i] * k<=1000000000&&isExist[v[i]*k]==true&&isExist[v[i]]){
            isExist[v[i]*k]=false;
            ans--;
        }
        //else {cout<<v[i]<<"\n"; break;}
    }
    print ans;
}


#include<bits/stdc++.h>
using namespace std;
#define all(v) v.begin(),v.end()
#define V vector
#define S string
#define pb push_back
#define sz size()
#define get cin>>
#define print cout<<
typedef long long ll;
typedef unsigned long long ull;
int main(){
	cin.tie(0);
	std::ios::sync_with_stdio(false);
	int n, k; get n >> k;
	V<int> v(n); bool isExist[100000 + 1] = { 0 };
	for (int i = 0; i<n; i++){ get v[i]; isExist[v[i]] = 1; }
	sort(all(v));
	for (int i = 0; i<v.sz; i++){
		if (isExist[v[i] * k]){
              isExist[v[i] * k]=0;
			v.erase(find(v.begin(), v.end(), v[i] * k));
			i--;
		}
	}
	print v.sz;
}


#include<bits/stdc++.h>
using namespace std;
#define all(v) v.begin(),v.end()
#define V vector
#define S string
#define pb push_back
#define sz size()
#define get cin>>
#define print cout<<
typedef long long ll;
typedef unsigned long long ull;
int main(){
	cin.tie(0);
	std::ios::sync_with_stdio(false);
	ll n, k; get n >> k;
	V<ll> v(n); V<bool> isExist(1000000000+1,0);
	for (int i = 0; i<n; i++){ get v[i]; isExist[v[i]] = 1; }
	sort(all(v));
	for (int i = 0; i<v.sz; i++){
		if (isExist[v[i] * k]){
              isExist[v[i] * k]=0;
			v.erase(find(v.begin(), v.end(), v[i] * k));
			i--;
		}
	}
	print v.sz;
}


#include<bits/stdc++.h>
using namespace std;
#define all(v) v.begin(),v.end()
#define V vector
#define S string
#define pb push_back
#define sz size()
#define get cin>>
#define print cout<<
typedef long long ll;
typedef unsigned long long ull;
int main(){
    cin.tie(0);
    std::ios::sync_with_stdio(false);
    ll n, k; get n >> k;
    int v[n]; V<bool> isExist(1000000000+1,false);
    for (int i = 0; i<n; i++){ get v[i]; isExist[v[i]] = true; }
    sort(v,v+n); int ans=n;
    if(n==1){cout<<1; return 0;}
    for (int i = 0; i<n; i++){
        if (v[i] * k<=1000000000&&isExist[v[i]*k]==true&&isExist[v[i]]){
            isExist[v[i]*k]=false;
            ans--;
        }
        //else {cout<<v[i]<<"\n"; break;}
    }
    print ans;
}


#include<bits/stdc++.h>
using namespace std;
#define all(v) v.begin(),v.end()
#define V vector
#define S string
#define pb push_back
#define sz size()
#define get cin>>
#define print cout<<
typedef long long ll;
typedef unsigned long long ull;
int main(){
    cin.tie(0);
    std::ios::sync_with_stdio(false);
    ll n, k; get n >> k;
    V<ll> v(n); V<bool> isExist(1000000000+1,0);
    for (int i = 0; i<n; i++){ get v[i]; isExist[v[i]] = 1; }
    sort(all(v));
    for (int i = 0; i<v.sz; i++){
        if (v[i] * k<=1000000000&&isExist[v[i] * k]&&!v.empty()){
            isExist[v[i] * k]=0;
            v.erase(find(v.begin(), v.end(), v[i] * k));
            i--;
        }
    }
    print v.sz;
}


#include <bits/stdc++.h>
#define l long long
#define sl set<l>
#define it sl::iterator
#define rep(i,n) for(l i=0;i<n;i++)

using namespace std;

int main() {
    l n,k,x,c=0; cin>>n>>k;
    sl s;
    it itx;
    rep(i,n){cin>>x;s.insert(x);}
    for(it i=s.begin();i!=s.end();i++){
        itx=s.find(k*(*i));
        if(itx!=s.end()){
            s.erase(itx);
        }
        c++;
    }
    cout<<c;
    return 0;
}


#include <bits/stdc++.h>
#define l long long
#define sl set<l>
#define rep(i,n) for(l i=0;i<n;i++)

using namespace std;

l f(sl s,l k,l max){
    if(s.begin()==s.end()){
        return 0;
    }
    l t=s.size(),comp=0;
    if(t==1){
        return ++max;
    }
    sl::iterator itx=s.find(k*(*s.begin()));
    if(itx!=s.end()){
        s.erase(itx);
    }
    s.erase(s.begin());
    comp=f(s,k,++max);
    if(comp>max){
        max=comp;
    }
    return max;
}

int main() {
    l n,k,x,max=0; cin>>n>>k;
    sl s;
    rep(i,n){cin>>x;s.insert(x);}
    rep(i,n){
        x=f(s,k,0);
        max=(x>max)?x:max;
        s.erase(s.begin());
        if(s.size()<=max){
            break;
        }
    }
    cout<<max;
    return 0;
}


#include <bits/stdc++.h>
#define l long long
#define sl set<l>
#define rep(i,n) for(l i=0;i<n;i++)

using namespace std;

int main() {
    l n,k,x; cin>>n>>k;
    sl s;
    rep(i,n){
        cin>>x;
        if(x!=k){
            x=(x%k==0)?x/k:x;
        }
        s.insert(x);
    }
    cout<<s.size();
    return 0;
}


#include <bits/stdc++.h>
#define l long long
#define sl set<l>
#define it sl::iterator
#define rep(i,n) for(l i=0;i<n;i++)

using namespace std;

int main() {
    l n,k,x,c=0; cin>>n>>k;
    sl s;
    rep(i,n){cin>>x;s.insert(x);}
    it i=s.begin(),itx=s.find(k*(*i)),ity=i;
    if(itx!=s.end()){
        ity=itx;
    }
    i++;
    c++;
    for(;i!=s.end();i++){
        if((*ity)==(*i)){
            continue;
        }
        itx=s.find(k*(*i));
        if(itx!=s.end()){
            ity=itx;
        }
        c++;
    }
    cout<<c;
    return 0;
}


#include <bits/stdc++.h>
#define l long long
#define sl set<l>
#define rep(i,n) for(l i=0;i<n;i++)

using namespace std;

l f(sl s,l k,l max){
    if(s.begin()==s.end()){
        return 0;
    }
    l t=s.size(),comp=0;
    if(t==1){
        return ++max;
    }
    sl::iterator itx=s.find(k*(*s.begin()));
    if(itx!=s.end()){
        s.erase(itx);
    }
    s.erase(s.begin());
    comp=f(s,k,++max);
    if(comp>max){
        max=comp;
    }
    return max;
}

int main() {
    l n,k,x,max=0; cin>>n>>k;
    sl s;
    rep(i,n){cin>>x;s.insert(x);}
    x=f(s,k,0);
    cout<<max;
    return 0;
}


#include <bits/stdc++.h>
#define l long long
#define sl set<l>
#define it sl::iterator
#define rep(i,n) for(l i=0;i<n;i++)

using namespace std;

int main() {
    l n,k,x,c=0; cin>>n>>k;
    sl s;
    //map<l,l> m;
    it itx;
    rep(i,n){cin>>x;s.insert(x);}
    for(it i=s.begin();i!=s.end();i++){
        itx=s.find(k*(*i));
        if(itx!=s.end()){
            s.erase(itx);
        }
        c++;
    }
    cout<<c;
    return 0;
}


#include <bits/stdc++.h>
#define l long long
#define sl set<l>
#define it sl::iterator
#define rep(i,n) for(l i=0;i<n;i++)

using namespace std;

int main() {
    l n,k,x,c=0; cin>>n>>k;
    sl s;
    it itx;
    rep(i,n){cin>>x;s.insert(x);}
    map<l,l> m;
    for(it i=s.begin();i!=s.end();i++){
        if((*i)==m[*i]){
            continue;
        }
        itx=s.find(k*(*i));
        if(itx!=s.end()){
            m[*itx]=(*itx);
        }
        c++;
    }
    cout<<c;
    return 0;
}


#include <cstdio>
#include <vector>
#include <set>
#include <cmath>
#include <map>
#include <algorithm>

using namespace std;
vector<int> numbers;
int n, k;

int round_up(int n) {
	//if (n == 1) return 1;
	if (n%2) return (n/2) + 1;
	else return n/2;
}

int main() {
	scanf("%d %d", &n, &k); numbers.resize(n);
	for (int i=0; i < n; i++) scanf("%d", &numbers[i]);

	map<int, int> all_nums; for (int i=0; i < n; i++) all_nums.insert(make_pair(numbers[i], i));

	vector<vector<int> > links(n);
	vector<int> linked(n, 0);

	for (int i=0; i < n; i++) {
		if (!linked[i]) {
			int curr = numbers[i]; links[i].push_back(0); linked[i] = 1;
			while (true) {

			map<int, int>::iterator it = all_nums.find(curr*k);
			if (it != all_nums.end()) {
				links[i].push_back(it->first);
				linked[it->second] = 1;
			}
			else break;

			curr *= k;
			}
		}
	}

	int ans = 0; for (int i=0; i < n; i++) ans += round_up(links[i].size());
	printf("%d\n", ans);

}


#include <cstdio>
#include <vector>
#include <set>
#include <cmath>
#include <map>
#include <algorithm>

using namespace std;
vector<int> numbers;
int n, k;

int round_up(int n) {
	//if (n == 1) return 1;
	if (n%2) return (n/2) + 1;
	else return n/2;
}

int main() {
	scanf("%d %d", &n, &k); numbers.resize(n);
	for (int i=0; i < n; i++) scanf("%d", &numbers[i]);

	map<int, int> all_nums; for (int i=0; i < n; i++) all_nums.insert(make_pair(numbers[i], i));

	vector<vector<int> > links(n);
	vector<int> linked(n, 0);

	for (int i=0; i < n; i++) {
		if (!linked[i]) {
			int curr = numbers[i]; links[i].push_back(0); linked[i] = 1;
			while (true) {

			map<int, int>::iterator it = all_nums.find(curr*k);
			if (it != all_nums.end()) {
				links[i].push_back(it->first);
				linked[it->second] = 1;
			}
			else break;

			if (curr > 1e9) break;
			curr *= k;

			}
		}
	}

	int ans = 0; for (int i=0; i < n; i++) ans += round_up(links[i].size());
	printf("%d\n", ans);

}


#include <cstdio>
#include <vector>
#include <set>
#include <cmath>
#include <map>
#include <algorithm>

using namespace std;
vector<int> numbers;
int n, k;

int round_up(int n) {
	//if (n == 1) return 1;
	if (n%2) return (n/2) + 1;
	else return n/2;
}

int main() {
	scanf("%d %d", &n, &k); numbers.resize(n);
	for (int i=0; i < n; i++) scanf("%d", &numbers[i]);

	sort(numbers.begin(), numbers.end());

	set<int> numbers_final;
	for (int i=0; i < n; i++) {

		set<int>::iterator it = numbers_final.find(numbers[i]/k);
		if (it == numbers_final.end() || numbers[i] % k) numbers_final.insert(numbers[i]);
		else continue;
	}

	int ans = numbers_final.size();
	printf("%d\n", ans);

}


#include <cstdio>
#include <vector>
#include <set>
#include <cmath>
#include <map>
#include <algorithm>

using namespace std;
vector<int> numbers;
int n, k;

int round_up(int n) {
	//if (n == 1) return 1;
	if (n%2) return (n/2) + 1;
	else return n/2;
}

int main() {
	scanf("%d %d", &n, &k); numbers.resize(n);
	for (int i=0; i < n; i++) scanf("%d", &numbers[i]);

	sort(numbers.begin(), numbers.end());

	set<int> numbers_final;
	for (int i=0; i < n; i++) {
		set<int>::iterator it = numbers_final.find(numbers[i]/k);
		if (it == numbers_final.end()) numbers_final.insert(numbers[i]);
		else continue;
	}

	int ans = numbers_final.size();
	printf("%d\n", ans);

}


#include <cstdio>
#include <vector>
#include <set>
#include <cmath>
#include <map>
#include <algorithm>

using namespace std;
vector<int> numbers;
int n, k;

int round_up(int n) {
	if (n%2) return (n/2) + 1;
	else return n/2;
}

int main() {
	scanf("%d %d", &n, &k); numbers.resize(n);
	for (int i=0; i < n; i++) scanf("%d", &numbers[i]);

	map<int, int> all_nums; for (int i=0; i < n; i++) all_nums.insert(make_pair(numbers[i], i));

	vector<vector<int> > links(n);
	vector<int> linked(n, 0);

	for (int i=0; i < n; i++) {
		if (!linked[i]) {
			int curr = numbers[i]; links[i].push_back(0);
			while (true) {

			map<int, int>::iterator it = all_nums.find(curr*k);
			if (it != all_nums.end()) {
				links[i].push_back(it->first);
				linked[it->second] = 1;
			}
			else break;

			curr *= k;
			}
		}
	}

	int ans = 0; for (int i=0; i < n; i++) ans += round_up(links[i].size());
	printf("%d\n", ans);

}


#include<bits/stdc++.h>

#define MOD 1000000007
#define MODSET(d) if ((d) >= MOD) d %= MOD;

using namespace std;

int arr[100005];

set<int> data;

int main()
{
    #ifdef VSP4
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

	int n, k, i, j, d, maxSize = 0;
	bool add;

	cin >> n >> k;

	for (i = 0; i < n; i++)
	{
        cin >> arr[i];
	}

    sort(arr, arr + n);

    for (i = n-1; i >= 0; i--)
    {
        d = arr[i];
        if (data.find(k*d) == data.end())
        {
            data.insert(d);
            maxSize++;
        }
        else
        {
            cout << k*d << "\n";
        }
    }

    cout << maxSize;

    return 0;
}


#include<bits/stdc++.h>

#define MOD 1000000007
#define MODSET(d) if ((d) >= MOD) d %= MOD;

using namespace std;

int arr[100005];

set<int> data;

int main()
{
    #ifdef VSP4
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

	int n, k, i, j, d, maxSize = 0;
	bool add;

	cin >> n >> k;

	for (i = 0; i < n; i++)
	{
        cin >> arr[i];
	}

    sort(arr, arr + n);

    for (i = n-1; i >= 0; i--)
    {
        d = arr[i];
        if (data.find(k*d) == data.end())
        {
            data.insert(d);
            maxSize++;
        }
        else
        {
        if (n == 100000)
            cout << k*d << "\n";
        }
    }

    cout << maxSize;

    return 0;
}


#include<bits/stdc++.h>

#define MOD 1000000007
#define MODSET(d) if ((d) >= MOD) d %= MOD;

using namespace std;

int arr[100005];

unordered_set<int> data;

int main()
{
    #ifdef VSP4
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

	int n, k, i, j, d, maxSize = 0;
	bool add;

	cin >> n >> k;

	for (i = 0; i < n; i++)
	{
        cin >> arr[i];
	}

    sort(arr, arr + n);

    n = unique(arr, arr + n) - arr;

    for (i = n-1; i >= 0; i--)
    {
        d = arr[i];
        if (data.find(k*d) == data.end())
        {
            data.insert(d);
            maxSize++;
        }
    }

    cout << maxSize;

    return 0;
}


#include<bits/stdc++.h>

#define MOD 1000000007
#define MODSET(d) if ((d) >= MOD) d %= MOD;

using namespace std;

int arr[100005];

unordered_set<int> data;

int main()
{
    #ifdef VSP4
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

	int n, k, i, j, d, maxSize = 0;
	bool add;

	cin >> n >> k;

	for (i = 0; i < n; i++)
	{
        cin >> arr[i];
	}

    sort(arr, arr + n);

    for (i = n-1; i >= 0; i--)
    {
        d = arr[i];
        if (k > 1e9/d || (k <= 1e9/d && data.find(k*d) == data.end()))
        {
            data.insert(d);
            maxSize++;
        }
    }

    cout << maxSize;

    return 0;
}


#include<bits/stdc++.h>

#define MOD 1000000007
#define MODSET(d) if ((d) >= MOD) d %= MOD;

using namespace std;

int arr[100005];

set<int> data;

int main()
{
    #ifdef VSP4
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

	int n, k, i, j, d, maxSize = 0;
	bool add;

	cin >> n >> k;

	for (i = 0; i < n; i++)
	{
        cin >> arr[i];
	}

    sort(arr, arr + n);

    for (i = n-1; i >= 0; i--)
    {
        d = arr[i];
        if (data.find(k*d) == data.end())
        {
            data.insert(d);
            maxSize++;
        }
    }

    cout << maxSize;

    return 0;
}


#include<bits/stdc++.h>

#define MOD 1000000007
#define MODSET(d) if ((d) >= MOD) d %= MOD;

using namespace std;

int arr[100005];

set<int> data;

int main()
{
    #ifdef VSP4
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

	int n, k, i, j, d, maxSize = 0;
	bool add;

	cin >> n >> k;

	for (i = 0; i < n; i++)
	{
        cin >> arr[i];
	}

    sort(arr, arr + n);

    for (i = n-1; i >= 0; i--)
    {
        d = arr[i];
        if (k <= 1e9/d && data.find(k*d) == data.end())
        {
            data.insert(d);
            maxSize++;
        }
    }

    cout << maxSize;

    return 0;
}


#include<bits/stdc++.h>

#define MOD 1000000007
#define MODSET(d) if ((d) >= MOD) d %= MOD;

using namespace std;

int arr[100005];

set<int> data;

int main()
{
    #ifdef VSP4
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

	int n, k, i, j, d, maxSize = 0;
	bool add;

	cin >> n >> k;

	for (i = 0; i < n; i++)
	{
        cin >> arr[i];
	}

    sort(arr, arr + n);

    for (i = n-1; i >= 0; i--)
    {
        d = arr[i];
        if (k > 1e9/d || (k <= 1e9/d && data.find(k*d) == data.end()))
        {
            data.insert(d);
            maxSize++;
        }
    }

    cout << maxSize;

    return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
ll n,k,a[100500],ans;
set<ll> used;
int main()
{
	cin>>n>>k;
	for (int i=0;i<n;i++) cin>>a[i];
	sort(a,a+n);
	for (int i=0;i<n;i++)
		if (used.count(a[i])==0)
		{
			ans++;
			used.insert(a[i]*k);
		}
	cout<<ans;
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
map<int,bool> have;
int n,k,ans,x;
int main()
{
	cin>>n>>k;
	for (int i=0;i<n;i++)
	{
		cin>>x;
		while (x%k==0) x/=k;
		if (have.count(x)) continue;
		have[x]=true;
		ans++;
	}
	cout<<ans;
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
set<int> bad;
int n,k,ans,a[100010];
int main()
{
	cin>>n>>k;
	for (int i=0;i<n;i++) cin>>a[i];
	sort(a,a+n);
	for (int i=n-1;i>=0;i--)
		if (bad.find(a[i])==bad.end())
		{
			ans++;
			if (a[i]%k==0) bad.insert(a[i]/k);
		}
	cout<<ans;
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
int n,k,a[100000],ans;
bool flag[100000];
int Find(int lef,int rig,int x)
{
	while (lef<=rig)
	{
		int mid=(lef+rig)/2;
		if (a[mid]==x) return mid;
		if (a[mid]<x) lef=mid+1;
		else rig=mid-1;
	}
	return -1;
}
int main()
{
	cin>>n>>k;
	for (int i=0;i<n;i++) cin>>a[i];
	sort(a,a+n);
	int Max=a[n-1]/k;
	for (int i=0;i<n;i++)
	{
		if (flag[i]) continue;
		int t=i,len=1;
		while (a[t]<=Max)
		{
			t=Find(t+1,n-1,a[t]*k);
			if (t==-1) break;
			flag[t]=true;
			len++;
		}
		ans+=(len+1)/2;
	}
	cout<<ans;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int lim=1000000000;
int n,k,res,a;
set<int> s;
int main()
{
	cin>>n>>k;
	while (n--) cin>>a,s.insert(a);
	while (!s.empty())
	{
		int x=*s.begin();
		int cnt=0;
		while (true)
		{
			if (s.count(x)) s.erase(x),cnt++;
			if (x<=lim/k) x*=k;
			else break;
		}
		res+=(cnt+1)/2;
	}
	cout<<res;
	return 0;
}


#include <iostream>
#include <map>
using namespace std;

int main() {
	int n, k, count=0;
	map<int,bool> A;
	cin >> n >> k;
	for(int i=0; i<n; i++) {
		int x; cin >> x;
		A[x] = false;
	}
	for(map<int,bool>::iterator i = A.begin(); i != A.end(); i++) {
		if(i->second == false && i->first <= 0x3fffffff) {
			if(A.count(i->first) * 2) {
				count++;
				A[i->first * 2] = true;
			}
		}
	}

	cout << n - count;
	return 0;
}


#include <iostream>
#include <map>
using namespace std;

int main() {
	int n, k, count=0;
	map<int,bool> A;
	cin >> n >> k;
	for(int i=0; i<n; i++) {
		int x; cin >> x;
		A[x] = false;
	}
	for(map<int,bool>::iterator i = A.begin(); i != A.end(); i++) {
		if(i->second == false && i->first <= 0x3fffffff) {
			if(A.count(i->first * 2)) {
				count++;
				A[i->first * 2] = true;
			}
		}
	}

	cout << n - count;
	return 0;
}


#include <iostream>
#include <map>
using namespace std;

int main() {
	int n, k, count;
	map<int,bool> A;
	cin >> n >> k;
	for(int i=0; i<n; i++) {
		int x; cin >> x;
		A[x] = false;
	}
	for(map<int,bool>::iterator i = A.begin(); i != A.end(); i++) {
		if(i->second == false && i->first <= 0x3fffffff) {
			if(A.count(i->first) * 2) {
				count++;
				A[i->first * 2] = true;
			}
		}
	}

	cout << n - count;
	return 0;
}


#include <iostream>
#include <map>
using namespace std;

typedef long long ll;

int main() {
    int n, k, count=0;
    map<ll,bool> A;
    cin >> n >> k;
    for(int i=0; i<n; i++) {
        ll x; cin >> x;
        A[x] = false;
    }
    for(map<ll,bool>::iterator i = A.begin(); i != A.end(); i++) {
        if(i->second == false) {
            if(A.count(i->first * k)) {
                count++;
                A[i->first * k] = true;
            }
        }
    }

    cout << n - count;
    return 0;
}


#include <iostream>
#include <map>
using namespace std;

typedef long long ll;

int main() {
	int n, k, count=0;
	map<ll,bool> A;
	cin >> n >> k;
	for(int i=0; i<n; i++) {
		ll x; cin >> x;
		A[x] = false;
	}
	for(map<ll,bool>::iterator i = A.begin(); i != A.end(); i++) {
		if(i->second == false) {
			if(A.count(i->first * 2)) {
				count++;
				A[i->first * 2] = true;
			}
		}
	}

	cout << n - count;
	return 0;
}


#include <iostream>
#include <map>
using namespace std;

typedef long long ll;

int main() {
    int n, k, count=0;
    map<ll,bool> A;
    cin >> n >> k;
    for(int i=0; i<n; i++) {
        ll x; cin >> x;
        A[x] = false;
    }
    for(map<ll,bool>::iterator i = A.begin(); i != A.end(); i++) {
        if(i->second == false) {
            if(A.count(i->first * k) && k > 1) {
                count++;
                A[i->first * k] = true;
            }
        }
    }

    cout << n - count;
    return 0;
}


/*
   ~~~ BISMILLAH HIR RAHMANIR RAHIM ~~~
   Problem Name:
       Platform:
     Algorithom:
  Author's Name: RC Tushar

                 শুনেছি তোমার ভীষণ রাগ ?
                              সে কি রাগ , নাকি
                                     মগজ কোণে পচন ধরা
                 পুরনো কোডের বাগ ?

 ~~~     Never Lost Hope     ~~~
*/
#include<bits/stdc++.h>
#define pi 2*acos(0.0)
#define PS system("pause")
#define siter(n,T1)  for(set<T1>::iterator it=n.begin();it!=n.end();it++)
#define miter(n,T1,T2)  for(map<T1,T2>::iterator it=n.begin();it!=n.end();it++)
#define meter(n,T1,T2)  for(map<T1,T2>::iterator it=n.end();it!=n.begin();it--)
#define FOR(s,e,inc) for(int i=s;i<=e;i+=inc)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define Sfor(n) for(int i=1;i<=n;i++)
#define inf (1<<30)
#define pb push_back
#define ppb pop_back
#define F first
#define S second
#define sz(x) ((int)x.size())
#define eps 1e-9
#define gcd(x,y) __gcd(x,y)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define on(x,w)  x=x|(1<<w)
#define check(x,w) (x&(1<<w))==(1<<w)?true:false
#define all(x) (x).begin(),(x).end()
#define s(n) scanf("%d",&n)
#define sl(n) scanf("%lld",&n)
#define pf printf
#define ll long long int
#define ull unsigned long long int
#define MOD 1000000007
#define sqr(x) (( (x)* (x))%MOD)
#define cube(x)   ( (sqr(x)*(x))%MOD)
#define bit_cnt(x)   __builtin_popcount(x)
#define INT(c)  ((int)((c) - '0'))
#define CHAR(i) ((char)(i + int('0')))
#define maxall(v) *max_element(all(v))
#define minall(v) *min_element(all(v))
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define btz(a)   __builtin_ctz(a)
#define Mems(p,n) memset(p, n, sizeof(p))
#define makeint(n,s)  istringstream(s)>>n
#define BOUNDARY(i,j,Row,Col) ((i >= 0 && i < Row) && (j >= 0 && j < Col))
#define ubound(d,val)  int (upper_bound (d.begin(), d.end(), val) - d.begin())
#define lbound(d,val)  int (lower_bound (d.begin(), d.end(), val) - d.begin())
#define M 100003
using namespace std;

int dx[]= {1,0,-1,0};
int dy[]= {0,1,0,-1};                        //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};     //8 direction
//int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};   //Knight Direction
//int dx[]={2,1,-1,-2,-1,1};int dy[]={0,1,1,0,-1,-1};              //Hexagonal Direction
//freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);

typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ll,bool> pib;
typedef pair<double,int> pdi;
typedef pair<int,char> pic;
typedef pair< int, pii> ipii;

//FAST_INPUT
template<class T>
inline bool fs(T &x)
{
    int c=getchar();
    int sgn=1;
    while(~c&&c<'0'||c>'9')
    {
        if(c=='-')sgn=-1;
        c=getchar();
    }
    for(x=0; ~c&&'0'<=c&&c<='9'; c=getchar())
        x=x*10+c-'0';
    x*=sgn;
    return ~c;
}

map<int ,bool> ara;
int mara[M+5];
int main()
{
    int k,n,x;
    fs(n);
    fs(k);

    loop(i,0,n)
    {
        fs(x);
        mara[i]=x;
        ara[x]=true;
    }

    loop(i,0,n)
    ara[mara[i]*k]=false;

    int sum=0;
    miter(ara,int,bool)
    sum+=it->S;

    cout<<sum<<endl;
    return 0;
}


/*
   ~~~ BISMILLAH HIR RAHMANIR RAHIM ~~~
   Problem Name:
       Platform:
     Algorithom:
  Author's Name: RC Tushar

                 শুনেছি তোমার ভীষণ রাগ ?
                              সে কি রাগ , নাকি
                                     মগজ কোণে পচন ধরা
                 পুরনো কোডের বাগ ?

 ~~~     Never Lost Hope     ~~~
*/
#include<bits/stdc++.h>
#define pi 2*acos(0.0)
#define PS system("pause")
#define siter(n,T1)  for(set<T1>::iterator it=n.begin();it!=n.end();it++)
#define miter(n,T1,T2)  for(map<T1,T2>::iterator it=n.begin();it!=n.end();it++)
#define meter(n,T1,T2)  for(map<T1,T2>::iterator it=n.end();it!=n.begin();it--)
#define FOR(s,e,inc) for(int i=s;i<=e;i+=inc)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define Sfor(n) for(int i=1;i<=n;i++)
#define inf (1<<30)
#define pb push_back
#define ppb pop_back
#define F first
#define S second
#define sz(x) ((int)x.size())
#define eps 1e-9
#define gcd(x,y) __gcd(x,y)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define on(x,w)  x=x|(1<<w)
#define check(x,w) (x&(1<<w))==(1<<w)?true:false
#define all(x) (x).begin(),(x).end()
#define s(n) scanf("%d",&n)
#define sl(n) scanf("%lld",&n)
#define pf printf
#define ll long long int
#define ull unsigned long long int
#define MOD 1000000007
#define sqr(x) (( (x)* (x))%MOD)
#define cube(x)   ( (sqr(x)*(x))%MOD)
#define bit_cnt(x)   __builtin_popcount(x)
#define INT(c)  ((int)((c) - '0'))
#define CHAR(i) ((char)(i + int('0')))
#define maxall(v) *max_element(all(v))
#define minall(v) *min_element(all(v))
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define btz(a)   __builtin_ctz(a)
#define Mems(p,n) memset(p, n, sizeof(p))
#define makeint(n,s)  istringstream(s)>>n
#define BOUNDARY(i,j,Row,Col) ((i >= 0 && i < Row) && (j >= 0 && j < Col))
#define ubound(d,val)  int (upper_bound (d.begin(), d.end(), val) - d.begin())
#define lbound(d,val)  int (lower_bound (d.begin(), d.end(), val) - d.begin())
#define M 100003
using namespace std;

//int dx[]= {1,0,-1,0};
//int dy[]= {0,1,0,-1};                        //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};     //8 direction
//int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};   //Knight Direction
//int dx[]={2,1,-1,-2,-1,1};int dy[]={0,1,1,0,-1,-1};              //Hexagonal Direction
//freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);

typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ll,bool> pib;
typedef pair<double,int> pdi;
typedef pair<int,char> pic;
typedef pair< int, pii> ipii;

//FAST_INPUT
template<class T>
inline bool fs(T &x)
{
    int c=getchar();
    int sgn=1;
    while(~c&&c<'0'||c>'9')
    {
        if(c=='-')sgn=-1;
        c=getchar();
    }
    for(x=0; ~c&&'0'<=c&&c<='9'; c=getchar())
        x=x*10+c-'0';
    x*=sgn;
    return ~c;
}

map<ll ,ll> ara;
ll mara[M+5];
int main()
{
    ll k,n,x;
    fs(n);
    fs(k);

    loop(i,0,n)
    {
        fs(x);
        mara[i]=x;
        ara[x]=1;
    }
    sort(mara,mara+n);

    for(int i=n-1;i>=0;i--)
    {
        if(!ara[mara[i]*k])
            ara[mara[i]]=2;
        else
            break;
    }

    for(int i=0;i<n;i++)
    {
        if(ara[mara[i]]==1)
        {
            if(ara[mara[i]*k]==1)
            ara[mara[i]*k]=0;
            if(ara[mara[i]*k]==2)
                ara[mara[i]]=0;
        }
    }

    int sum=0;

    for(int i=0;i<n;i++)
    {
        if(ara[mara[i]]!=0)
        sum++;
    }

    cout<<sum<<endl;
    return 0;
}


/*
   ~~~ BISMILLAH HIR RAHMANIR RAHIM ~~~
   Problem Name:
       Platform:
     Algorithom:
  Author's Name: RC Tushar

                 শুনেছি তোমার ভীষণ রাগ ?
                              সে কি রাগ , নাকি
                                     মগজ কোণে পচন ধরা
                 পুরনো কোডের বাগ ?

 ~~~     Never Lost Hope     ~~~
*/
#include<bits/stdc++.h>
#define pi 2*acos(0.0)
#define PS system("pause")
#define siter(n,T1)  for(set<T1>::iterator it=n.begin();it!=n.end();it++)
#define miter(n,T1,T2)  for(map<T1,T2>::iterator it=n.begin();it!=n.end();it++)
#define meter(n,T1,T2)  for(map<T1,T2>::iterator it=n.end();it!=n.begin();it--)
#define FOR(s,e,inc) for(int i=s;i<=e;i+=inc)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define Sfor(n) for(int i=1;i<=n;i++)
#define inf (1<<30)
#define pb push_back
#define ppb pop_back
#define F first
#define S second
#define sz(x) ((int)x.size())
#define eps 1e-9
#define gcd(x,y) __gcd(x,y)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define on(x,w)  x=x|(1<<w)
#define check(x,w) (x&(1<<w))==(1<<w)?true:false
#define all(x) (x).begin(),(x).end()
#define s(n) scanf("%d",&n)
#define sl(n) scanf("%lld",&n)
#define pf printf
#define ll long long int
#define ull unsigned long long int
#define MOD 1000000007
#define sqr(x) (( (x)* (x))%MOD)
#define cube(x)   ( (sqr(x)*(x))%MOD)
#define bit_cnt(x)   __builtin_popcount(x)
#define INT(c)  ((int)((c) - '0'))
#define CHAR(i) ((char)(i + int('0')))
#define maxall(v) *max_element(all(v))
#define minall(v) *min_element(all(v))
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define btz(a)   __builtin_ctz(a)
#define Mems(p,n) memset(p, n, sizeof(p))
#define makeint(n,s)  istringstream(s)>>n
#define BOUNDARY(i,j,Row,Col) ((i >= 0 && i < Row) && (j >= 0 && j < Col))
#define ubound(d,val)  int (upper_bound (d.begin(), d.end(), val) - d.begin())
#define lbound(d,val)  int (lower_bound (d.begin(), d.end(), val) - d.begin())
#define M 100003
using namespace std;

int dx[]= {1,0,-1,0};
int dy[]= {0,1,0,-1};                        //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};     //8 direction
//int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};   //Knight Direction
//int dx[]={2,1,-1,-2,-1,1};int dy[]={0,1,1,0,-1,-1};              //Hexagonal Direction
//freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);

typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ll,bool> pib;
typedef pair<double,int> pdi;
typedef pair<int,char> pic;
typedef pair< int, pii> ipii;

//FAST_INPUT
template<class T>
inline bool fs(T &x)
{
    int c=getchar();
    int sgn=1;
    while(~c&&c<'0'||c>'9')
    {
        if(c=='-')sgn=-1;
        c=getchar();
    }
    for(x=0; ~c&&'0'<=c&&c<='9'; c=getchar())
        x=x*10+c-'0';
    x*=sgn;
    return ~c;
}

map<ll ,ll> ara;
ll mara[M+5];
int main()
{
    ll k,n,x;
    fs(n);
    fs(k);

    loop(i,0,n)
    {
        fs(x);
        mara[i]=x;
        ara[x]=true;
    }

    loop(i,0,n)
    ara[mara[i]*k]=0;

    int sum=0;
    miter(ara,ll,ll)
    sum+=it->S;

    cout<<sum<<endl;
    return 0;
}


/*
   ~~~ BISMILLAH HIR RAHMANIR RAHIM ~~~
   Problem Name:
       Platform:
     Algorithom:
  Author's Name: RC Tushar

                 শুনেছি তোমার ভীষণ রাগ ?
                              সে কি রাগ , নাকি
                                     মগজ কোণে পচন ধরা
                 পুরনো কোডের বাগ ?

 ~~~     Never Lost Hope     ~~~
*/
#include<bits/stdc++.h>
#define pi 2*acos(0.0)
#define PS system("pause")
#define siter(n,T1)  for(set<T1>::iterator it=n.begin();it!=n.end();it++)
#define miter(n,T1,T2)  for(map<T1,T2>::iterator it=n.begin();it!=n.end();it++)
#define meter(n,T1,T2)  for(map<T1,T2>::iterator it=n.end();it!=n.begin();it--)
#define FOR(s,e,inc) for(int i=s;i<=e;i+=inc)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define Sfor(n) for(int i=1;i<=n;i++)
#define inf (1<<30)
#define pb push_back
#define ppb pop_back
#define F first
#define S second
#define sz(x) ((int)x.size())
#define eps 1e-9
#define gcd(x,y) __gcd(x,y)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define on(x,w)  x=x|(1<<w)
#define check(x,w) (x&(1<<w))==(1<<w)?true:false
#define all(x) (x).begin(),(x).end()
#define s(n) scanf("%d",&n)
#define sl(n) scanf("%lld",&n)
#define pf printf
#define ll long long int
#define ull unsigned long long int
#define MOD 1000000007
#define sqr(x) (( (x)* (x))%MOD)
#define cube(x)   ( (sqr(x)*(x))%MOD)
#define bit_cnt(x)   __builtin_popcount(x)
#define INT(c)  ((int)((c) - '0'))
#define CHAR(i) ((char)(i + int('0')))
#define maxall(v) *max_element(all(v))
#define minall(v) *min_element(all(v))
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define btz(a)   __builtin_ctz(a)
#define Mems(p,n) memset(p, n, sizeof(p))
#define makeint(n,s)  istringstream(s)>>n
#define BOUNDARY(i,j,Row,Col) ((i >= 0 && i < Row) && (j >= 0 && j < Col))
#define ubound(d,val)  int (upper_bound (d.begin(), d.end(), val) - d.begin())
#define lbound(d,val)  int (lower_bound (d.begin(), d.end(), val) - d.begin())
#define M 100003
using namespace std;

int dx[]= {1,0,-1,0};
int dy[]= {0,1,0,-1};                        //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};     //8 direction
//int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};   //Knight Direction
//int dx[]={2,1,-1,-2,-1,1};int dy[]={0,1,1,0,-1,-1};              //Hexagonal Direction
//freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);

typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ll,bool> pib;
typedef pair<double,int> pdi;
typedef pair<int,char> pic;
typedef pair< int, pii> ipii;

//FAST_INPUT
template<class T>
inline bool fs(T &x)
{
    int c=getchar();
    int sgn=1;
    while(~c&&c<'0'||c>'9')
    {
        if(c=='-')sgn=-1;
        c=getchar();
    }
    for(x=0; ~c&&'0'<=c&&c<='9'; c=getchar())
        x=x*10+c-'0';
    x*=sgn;
    return ~c;
}

map<ll ,ll> ara;
ll mara[M+5];
int main()
{
    ll k,n,x;
    fs(n);
    fs(k);

    loop(i,0,n)
    {
        fs(x);
        mara[i]=x;
        ara[x]=true;
    }

    loop(i,0,n)
    if(ara[mara[i]])
    ara[mara[i]*k]=0;

    int sum=0;
    miter(ara,ll,ll)
    sum+=it->S;

    cout<<sum<<endl;
    return 0;
}