import java.io.OutputStreamWriter;
import java.io.BufferedWriter;
import java.util.Locale;
import java.io.OutputStream;
import java.util.RandomAccess;
import java.io.PrintWriter;
import java.util.AbstractList;
import java.io.Writer;
import java.util.List;
import java.util.Map;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.TreeMap;
import java.math.BigInteger;
import java.util.Collections;
import java.io.InputStream;

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

class TaskA {
    public void solve(int testNumber, InputReader in, OutputWriter out) {
        int n = in.nextInt();
        long k = in.nextInt();
        if (k == 1) {
            out.println(n);
            return;
        }
        long[] a = in.nextLongArray(n);
        ArrayUtils.safeSort(a);
        Map<Long, Integer> map = new TreeMap<Long, Integer>();
        for (int i = 0; i < n; i++) {
            map.put(a[i], i);
        }
        int answer = 0;
        boolean[] visited = new boolean[n];
        for (int i = 0; i < n; i++) {
            if (!visited[i]) {
                visited[i] = true;
                int count = 1;
                long cur = a[i];
                while (true) {
                    cur *= k;
                    Integer index = map.get(cur);
                    if (index == null)
                        break;
                    visited[index] = true;
                    count++;
                }
                answer += NumberUtils.upDiv(count, 2);
            }
        }
        out.println(answer);
    }
}

class InputReader {

    private InputStream... What is the time complexity of the previous code?