codeparrot/codecomplex huggingface dataset:
// Problem: 274_A. k-Multiple Free Set
// Time complexity: nlogn
import java.util.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

public class  test{
	
	// ArrayList<Integer> lis = new ArrayList<Integer>();
	// ArrayList<String> lis = new ArrayList<String>();
	//  PriorityQueue<P> que = new PriorityQueue<P>();
	// PriorityQueue<Integer> que = new PriorityQueue<Integer>();
	//  Stack<Integer> que = new Stack<Integer>();
    //	static long sum=0;
	// 1000000007 (10^9+7)
	static int mod = 1000000007;
	//static int mod = 1000000009,r=0;
   // static int dx[]={1,-1,0,0};
//	static int dy[]={0,0,1,-1};
//	static int dx[]={1,-1,0,0,1,1,-1,-1};
//  static int dy[]={0,0,1,-1,1,-1,1,-1};
	//static long H,L;
	//static Set<Integer> set = new HashSet<Integer>();
public  static void main(String[] args)   throws Exception, IOException{
   //String line=""; throws Exception, IOException
   //(line=br.readLine())!=null
	//Scanner sc =new Scanner(System.in);
	// !!caution!! int long //  
	Reader sc = new Reader(System.in);
  // while( ){
	  // int  n=sc.nextInt(),m=sc.nextInt();//a[]=new int[n],b[]=new int[n];
	int  n=sc.nextInt(),r=0;long k=sc.nextInt();
    Integer x[]=new Integer[n];
	 boolean b[]=new boolean[n];
   
   for(int i=0;i<n;i++){
	   x[i]=sc.nextInt();
  }
   if( k==1 ){System.out.println(n); return;}
   sort(x);
   
   for(int i=0;i<n;i++){
	 if( b[i] )continue;
	 r++;
	 long p=x[i],pr=x[i];
	 while( p*k<=x[n-1] ) {p*=k;
	 
	 int up=n,dw=0,mid=(up+dw)/2;
	 boolean f=false;
	 while( up-dw!=1 ){
		 //db(p,x[mid]);
		 if( x[mid]==p ){f=true;break;}
		 if( p<x[mid] ){ up=mid; mid=(up+dw)/2; }
		 else { dw=mid; mid=(up+dw)/2; }
	 }
	  if( f ){ if(pr*k!=p){r++; pr=p;}   b[mid]=true;  } 
	  }
	
	 
  }

    System.out.println(r);
	   
}

static void db(Object... os){
    System.err.println(Arrays.deepToString(os));

}


}

class Reader
{
	private BufferedReader x;
	private StringTokenizer st;
	
	public Reader(InputStream in)
	{
		x = new BufferedReader(new InputStreamReader(in));
		st = null;
	}
	public String nextString() throws IOException
	{
		while( st==null || !st.hasMoreTokens() )
			st = new StringTokenizer(x.readLine());
		return st.nextToken();
	}
	public int nextInt() throws IOException
	{
		return Integer.parseInt(nextString());
	}
	public long nextLong() throws IOException
	{
		return Long.parseLong(nextString());
	}
	public double nextDouble() throws IOException
	{
		return Double.parseDouble(nextString());
	}
}

/*

class P implements Comparable<P>{
	int x,y;
	P(int x,int y){ this.x=x; this.y=y;  }
	
	public int compareTo(P z) {
	 if( x-z.x!=0)   return  x-z.x ;  //ascend 
	 else return  y-z.y ; 
	}
}
//*/
// Problem: 274_A. k-Multiple Free Set
// Time complexity: nlogn
import java.util.*;
import java.io.*;
public class a {
public static void main(String[] args) throws IOException
{
    input.init(System.in);
    int n = input.nextInt(), k = input.nextInt();
    TreeSet<Integer> ts = new TreeSet<Integer>();
    int[] data = new int[n];
    for(int i = 0; i<n; i++)
    {
        data[i] = input.nextInt();
    }
    Arrays.sort(data);
    if(n>1 && k==1.*data[n-1]/data[0])
        System.out.println(n-1);
    else
    {
    for(int i = 0; i<n; i++)
    {
        if(data[i]%k != 0)
            ts.add(data[i]);
        else
        {
            if(!ts.contains(data[i]/k))
                ts.add(data[i]);
        }
    }
    System.out.println(ts.size());
    }
}
public static class input {
    static BufferedReader reader;
    static StringTokenizer tokenizer;

    /** call this method to initialize reader for InputStream */
    static void init(InputStream input) {
        reader = new BufferedReader(
                     new InputStreamReader(input) );
        tokenizer = new StringTokenizer("");
    }

    /** get next word */
    static String next() throws IOException {
        while ( ! tokenizer.hasMoreTokens() ) {
            //TODO add check for eof if necessary
            tokenizer = new StringTokenizer(
                   reader.readLine() );
        }
        return tokenizer.nextToken();
    }

    static int nextInt() throws IOException {
        return Integer.parseInt( next() );
    }
    
    static double nextDouble() throws IOException {
        return Double.parseDouble( next() );
    }
    static long nextLong() throws IOException {
        return Long.parseLong( next() );
    }
}
}
// Problem: 274_A. k-Multiple Free Set
// Time complexity: nlogn
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.TreeSet;

public class Main {

	public static void main(String [] args ) {
		try{
			String str;			
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			BufferedOutputStream bos = new BufferedOutputStream(System.out);
			String eol = System.getProperty("line.separator");
			byte [] eolb = eol.getBytes();
			byte[] spaceb= " ".getBytes();
			
			
			str  = br.readLine();
			int blank = str.indexOf( " ");
			int n = Integer.parseInt(str.substring(0,blank));
			int m = Integer.parseInt(str.substring(blank+1));
			long [] num = new long[n];
			int j=0;
			int s=0;
			int k =0;
			str = br.readLine();
			int length = str.length();
			while(j<length) {
				while(j<length) {
					if(str.charAt(j) == ' ') {
						break;
					}else {
						j++;
					}
				}
				num[k] = Long.parseLong(str.substring(s,j)) ;
				k++;
				j++;
				s=j;			
			}
			Arrays.sort(num);
			int count = 0;
			if(m==1) {
				count = 1;
				for(int i = 1 ; i < n ; i++) {
					if(num[i]!=num[i-1]) {
						count++;
					} 
				}
			} else {
				TreeSet<Long> take = new TreeSet<Long>();
				TreeSet<Long> notTake = new TreeSet<Long>();
				for(int i = 0 ; i < n ; i++) {
					long temp = num[i];
					if(!notTake.contains(temp)){
						take.add(temp);
						temp *= ((long)m);
						notTake.add(temp);
					}
					
				}
				count = take.size();
			}
			bos.write(new Integer(count).toString().getBytes());
			bos.write(eolb);
			bos.flush();
		}  catch(IOException ioe) {
			ioe.printStackTrace();
		}
	}
}
// Problem: 274_A. k-Multiple Free Set
// Time complexity: nlogn
import static java.lang.Math.*;
import static java.util.Arrays.*;
import java.util.*;
import java.io.*;

public class Main {
	public static void main(String[] args) throws Exception {
		Class<?> here = new Object(){}.getClass().getEnclosingClass();
		try {
			String packageName = here.getPackage().getName();
			packageName = "src/" + packageName.replaceAll("\\.", "/") + "/";
			System.setIn(new FileInputStream(packageName + "input.txt"));
//			System.setOut(new PrintStream(new FileOutputStream(packageName + "output.txt")));
		} catch (FileNotFoundException e) {
		} catch (NullPointerException e) {
		}

		Object o = Class.forName(here.getName()).newInstance();
		o.getClass().getMethod("run").invoke(o);
	}

	static void tr(Object... os) {
		System.err.println(deepToString(os));
	}


	MyScanner sc = null;
	PrintWriter out = null;
	public void run() throws Exception {
		sc = new MyScanner(System.in);
		out = new PrintWriter(System.out);
		for (;sc.hasNext();) {
			solve();
			out.flush();
		}
		out.close();
	}

	void solve() {
		int n = sc.nextInt();
		int k = sc.nextInt();

		TreeSet<Integer> at = new TreeSet<Integer>();
		for (int i = 0; i < n; i++) at.add(sc.nextInt());
		Integer[] ai = at.toArray(new Integer[0]);
		int[] a = new int[n];
		for (int i = 0; i < n; i++) a[i] = ai[i];

		if (k == 1) {
			out.println(n);
			return;
		}

		boolean[] invalid = new boolean[n];

		tr(a);
		int ans = 0;
		for (int i = 0, j = 0; i < n; i++) if (!invalid[i]) {
			++ans;
			long kx = (long)k * a[i];
			while (j < n && a[j] < kx) {
				j++;
			}
			if (j < n && kx == a[j]) {
				invalid[j] = true;
			}
		}
		out.println(ans);

	}


	void print(int[] a) {
		out.print(a[0]);
		for (int i = 1; i < a.length; i++) out.print(" " + a[i]);
		out.println();
	}

	class MyScanner {
		String line;
		BufferedReader reader;
		StringTokenizer tokenizer;

		public MyScanner(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream));
			tokenizer = null;
		}

		public void eat() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					line = reader.readLine();
					if (line == null) {
						tokenizer = null;
						return;
					}
					tokenizer = new StringTokenizer(line);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
		}

		public String next() {
			eat();
			return tokenizer.nextToken();
		}

		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}

		public boolean hasNext() {
			eat();
			return (tokenizer != null && tokenizer.hasMoreElements());
		}

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

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

		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++) a[i] = nextInt();
			return a;
		}
	}
}
// Problem: 274_A. k-Multiple Free Set
// Time complexity: nlogn
import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class A {

    final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;
    BufferedReader in;
    PrintWriter out;
    StringTokenizer tok = new StringTokenizer("");

    void solve() throws IOException {
		int n = readInt();
		long k = readInt();
		Long[] a = new Long[n];
		for(int i = 0; i < n; i++){
			a[i] = readLong();
		}
		Arrays.sort(a);
		TreeSet<Long> set = new TreeSet<Long>();
		for(int i = 0; i < n; i++){
			set.add(a[i]);
		}
		if(k == 1) {
			out.println(n);
			return;
		}
		int res = 0;
		TreeSet<Long> used = new TreeSet<Long>();
		for(Long cur: set){
			if(!used.contains(cur)){
				int num = 1;
				used.add(cur);
				Long temp = cur * 1;
				
				while(true){
					if(set.contains(k*temp)){
						num++;
						used.add(k*temp);
						temp *= k;
					}
					else{
						res += (num+1)/2;
						break;
					}
				}
			}
		}
		out.println(res);


    }

    void init() throws FileNotFoundException {
        if (ONLINE_JUDGE) {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
        } else {
            in = new BufferedReader(new FileReader("input.txt"));
            out = new PrintWriter("output.txt");
        }
    }

    String readString() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine());
        }
        return tok.nextToken();
    }

    int readInt() throws IOException {
        return Integer.parseInt(readString());
    }

    long readLong() throws IOException {
        return Long.parseLong(readString());
    }

    double readDouble() throws IOException {
        return Double.parseDouble(readString());
    }

    int[] readArr(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = readInt();
        }
        return res;
    }

    long[] readArrL(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = readLong();
        }
        return res;
    }

    public static void main(String[] args) {
        new A().run();
    }

    public void run() {
        try {
            long t1 = System.currentTimeMillis();
            init();
            solve();
            out.close();
            long t2 = System.currentTimeMillis();
            System.err.println("Time = " + (t2 - t1));
        } catch (Exception e) {
            e.printStackTrace(System.err);
            System.exit(-1);
        }
    }
}
// Problem: 274_A. k-Multiple Free Set
// Time complexity: nlogn
import java.util.*;
import java.io.*;

public class solve {
	Scanner in;
	PrintWriter out;

	public void solve() throws IOException {
		int n = in.nextInt();
		long k = in.nextLong();
		int[] a = new int[n];
		Set<Long> b = new TreeSet<Long>();
		for (int i = 0; i < n; i++) {
			a[i] = in.nextInt();
		}
		Arrays.sort(a);
		int ans = 0;
		for (int i = n - 1; i >= 0; i--) {
			if (!b.contains((long) k * a[i])) {
				ans++;
				b.add((long) a[i]);
			}
		}
		out.print(ans);
	}

	public void run() {
		try {
			in = new Scanner(System.in);
			out = new PrintWriter(System.out);

			solve();

			out.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		FastScanner(File f) {
			try {
				br = new BufferedReader(new FileReader(f));
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			}
		}

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

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

	public static void main(String[] arg) {
		new solve().run();
	}
}
// Problem: 274_A. k-Multiple Free Set
// Time complexity: nlogn
import java.io.DataInputStream;
import java.io.InputStream;
import java.util.Arrays;
import java.util.TreeSet;

public class Main{

	
	public static void main(String[] args) throws Exception {
		Parserdoubt3 s = new Parserdoubt3(System.in);
		int n = s.nextInt();
		long k = s.nextInt();
		Long a[] = new Long[n];
		TreeSet<Long> tree = new TreeSet<Long>();
		for (int i = 0; i < a.length; i++) {
			a[i] = s.nextLong();
			tree.add(a[i]);
		}
		Arrays.sort(a);
		
		int ans = 0;
		
		for (int i = 0; i < a.length; i++) {
			if(tree.contains(a[i])){ 
				ans++;
				long next = a[i] * k;
				if(tree.contains(next)) tree.remove(next);
			}
		}
		System.out.println(ans);
	}

}

class Parserdoubt3 {
	final private int BUFFER_SIZE = 1 << 17;

	private DataInputStream din;
	private byte[] buffer;
	private int bufferPointer, bytesRead;

	public Parserdoubt3(InputStream in) {
		din = new DataInputStream(in);
		buffer = new byte[BUFFER_SIZE];
		bufferPointer = bytesRead = 0;
	}

	public String nextString() throws Exception {
		StringBuffer sb = new StringBuffer("");
		byte c = read();
		while (c <= ' ')
			c = read();
		do {
			sb.append((char) c);
			c = read();
		} while (c > ' ');
		return sb.toString();
	}

	public char nextChar() throws Exception {
		byte c = read();
		while (c <= ' ')
			c = read();
		return (char) c;
	}

	public int nextInt() throws Exception {
		int ret = 0;
		byte c = read();
		while (c <= ' ')
			c = read();
		boolean neg = c == '-';
		if (neg)
			c = read();
		do {
			ret = ret * 10 + c - '0';
			c = read();
		} while (c > ' ');
		if (neg)
			return -ret;
		return ret;
	}

	public long nextLong() throws Exception {
		long ret = 0;
		byte c = read();
		while (c <= ' ')
			c = read();
		boolean neg = c == '-';
		if (neg)
			c = read();
		do {
			ret = ret * 10 + c - '0';
			c = read();
		} while (c > ' ');
		if (neg)
			return -ret;
		return ret;
	}

	private void fillBuffer() throws Exception {
		bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
		if (bytesRead == -1)
			buffer[0] = -1;
	}

	private byte read() throws Exception {
		if (bufferPointer == bytesRead)
			fillBuffer();
		return buffer[bufferPointer++];
	}
}
// Problem: 274_A. k-Multiple Free Set
// Time complexity: nlogn
import java.io.*;
import java.util.*;
import java.math.*;
import java.awt.geom.*;

import static java.lang.Math.*;

public class Solution implements Runnable {
 	
	public void solve () throws Exception {
		int n = sc.nextInt();
		int k = sc.nextInt();
		
		TreeSet<Integer> bad = new TreeSet<>();
		int a [] = new int [n];
		for (int i = 0; i < n; i++)
			a[i] = sc.nextInt();
		
		Arrays.sort(a);
		
		int result = 0;
		for (int i = 0; i < n; i++) {
			if (!bad.contains(a[i])) {
				result++;
				long next = (long) a[i] * k;
				if (next <= 1000000000)
					bad.add((int) next);
			}
		}
		out.println(result);
	}
	
	BufferedReader in;
	PrintWriter out;
	FastScanner sc;

	static Throwable uncaught;

	@Override
	public void run() {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			sc = new FastScanner(in);
			solve();
		} catch (Throwable t) {
			Solution.uncaught = t;
		} finally {
			out.close();
		}
	}

	public static void main(String[] args) throws Throwable {
		Thread t = new Thread(null, new Solution(), "", (1 << 26));
		t.start();
		t.join();
		if (uncaught != null) {
			throw uncaught;
		}
	}

}

class FastScanner {

	BufferedReader reader;
	StringTokenizer strTok;

	public FastScanner(BufferedReader reader) {
		this.reader = reader;
	}

	public String nextToken() throws IOException {
		while (strTok == null || !strTok.hasMoreTokens()) {
			strTok = new StringTokenizer(reader.readLine());
		}
		return strTok.nextToken();
	}

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

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

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

}
// Problem: 274_A. k-Multiple Free Set
// Time complexity: nlogn
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Hashtable;
import java.util.Scanner;


public class f {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner in = new Scanner(System.in);
		Hashtable<Long, Boolean> d = new Hashtable<Long, Boolean>();
		int n = in.nextInt(), k = in.nextInt(), size = 0, a[] = new int[n];
		for (int i = 0; i < n; i++) a[i] = in.nextInt();
		Arrays.sort(a);
		for (int i = 0; i < n; i++) {
			long x = a[i];
			if (!d.containsKey(x)) {
				d.put(x * k, true);
				size++;
			}
		}
		System.out.println(size);
	}

}
// Problem: 274_A. k-Multiple Free Set
// Time complexity: nlogn
import java.io.*;
import java.util.*;
import java.util.Map.Entry;

public class Main {
	
	Scanner in;
	static PrintWriter out;
	
	
	static class Scanner {
		StreamTokenizer in;
		
		Scanner(InputStream is) {
			in = new StreamTokenizer(new BufferedReader(new InputStreamReader(is)));
			in.resetSyntax();
			in.whitespaceChars(0, 32);
			in.wordChars(33, 255);
		}
		
		String readLine() {
			try {
				in.nextToken();
				asserT(in.ttype == StreamTokenizer.TT_WORD);
				return in.sval;
			} catch (IOException e) {
				throw new Error();
			}
		}
		
		int nextInt() {
			return Integer.parseInt(readLine());			
		}
	}
	
	
	
	void solve() {
		int n = in.nextInt();
		long k = in.nextInt();
		int ar[] = new int[n];
		TreeMap <Integer, Integer> nums = new TreeMap<Integer, Integer>();
		for (int i = 0; i < n; i++) {
			ar[i] = in.nextInt();
			nums.put(ar[i], i);
		}
		
		if (k == 1) {
			out.println(n);
			return;
		}
		
		int next[] = new int[n];
		Arrays.fill(next, -1);
		
		int count = 0;
		
		for (int i = 0; i < n; i++) {
			long val = ar[i] * k;
			int intVal = (int)val;
			if (intVal == val) {
				if (nums.containsKey(intVal)) {
					int idx = nums.get(intVal);
					next[i] = idx;
					continue;
				}
			}
			
			if (ar[i] % k == 0) {
				intVal = ar[i] / (int)k;
				
				if (nums.containsKey(intVal)) {
					continue;
				}
			}
			
			
			count++;
		}
		
		for (int i = 0; i < n; i++) {
			int curr = nums.pollFirstEntry().getValue();
			boolean odd = false;
			while (next[curr] != -1) {
				if (!odd) {
					count++;
				}
				int to = next[curr];
				next[curr] = -1;
				curr = to;
				odd = !odd;
				
				if (next[curr] == -1) {
					if (!odd) {
						count++;
					}
				}
			}
		}
		out.println(count);
	}
	
	static void asserT(boolean e) {
		if (!e) {
			throw new Error();
		}
	}
	
	
	public void run() {
		in = new Scanner(System.in);
		out = new PrintWriter(System.out);
		
		try {
			solve();
		} finally {
			out.close();
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}

}
// Problem: 274_A. k-Multiple Free Set
// Time complexity: nlogn
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

public class ProblemA {
	
	public static void main(String[] args) throws IOException {
		BufferedReader s = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter out = new PrintWriter(System.out);
		
		String[] data = s.readLine().split(" ");
		int n = Integer.valueOf(data[0]);
		int k = Integer.valueOf(data[1]);
		
		
		long[] a = new long[n];
		String[] ai = s.readLine().split(" ");
		for (int i = 0 ; i < n ; i++) {
			a[i] = Integer.valueOf(ai[i]);
		}
		for (int i = 0 ; i < n ; i++) {
			int tm = (int)(Math.random() * n);
			long tmp = a[tm];
			a[tm] = a[i];
			a[i] = tmp;
		}
		Arrays.sort(a);

		Set<Long> invalid = new HashSet<Long>();
		int cnt = 0;
		for (int i = 0 ; i < n ; i++) {
			if (!invalid.contains(a[i])) {
				cnt++;
				invalid.add(a[i] * k);
			}
		}
		out.println(cnt);
		out.flush();
	}


	public static void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}
}
// Problem: 274_A. k-Multiple Free Set
// Time complexity: nlogn
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class A {

	public static void main(String[] args) throws IOException {
		InputReader in = new InputReader();
		int n = in.nextInt();
		long k = in.nextInt();
		Long[] a = new Long[n];
		for(int i = 0 ; i < n;i++)a[i]=in.nextLong();
		if(k==1)System.out.println(n);
		else{
			int res = 0;
			Arrays.sort(a);
			boolean[] v = new boolean[n];
			for(int i = 0 ; i < n;i++){
				if(!v[i]){
					long cur = a[i];
					int cnt = 1;
					while(true){
						int idx = Arrays.binarySearch(a, cur*k);
						if(idx<0){
							res+= cnt/2 + cnt%2;
							break;
							}
						v[idx]=true;
						cur = a[idx];
						cnt++;
					}
				}
			}
			System.out.println(res);
		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer st;

		public InputReader() throws IOException {
			in = new BufferedReader(new InputStreamReader(System.in));
			st = new StringTokenizer(in.readLine());
		}

		public String next() throws IOException {
			while (!st.hasMoreElements())
				st = new StringTokenizer(in.readLine());
			return st.nextToken();
		}

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

		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}
	}
}
// Problem: 274_A. k-Multiple Free Set
// Time complexity: nlogn

import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author NAO93
 */
public class a {
    public static void main(String[] args) {
        Scanner in = new  Scanner(System.in);
        int n = in.nextInt();
        long k = in.nextLong();
        Long []a = new Long[n];
        for (int i = 0; i<n; i++)
            a[i] = in.nextLong();
        HashSet<Long> hash = new HashSet<Long>();
        Arrays.sort(a);
        for (int i = 0; i<n; i++)
            if (!hash.contains(a[i])){
                hash.add(a[i] * k);
            }
        System.out.println(hash.size());
    }

}