#include <bits/stdc++.h>
int arr[100000];
int d[100000];
int cmp(const void *a, const void *b) {
  return (*((int *)a) > *((int *)b)) ? 1 : -1;
}
int main() {
  int i;
  int n, k;
  scanf("%d %d\n", &n, &k);
  for (i = 0; i < n; i++) {
    scanf("%d", &arr[i]);
  }
  qsort(arr, n, sizeof(int), cmp);
  int ans = 0;
  for (i = 0; i < n; i++) {
    int l = 0, r = i;
    while (l + 1 < r) {
      if (((long long)arr[(l + r) / 2]) * k > (long long)arr[i]) {
        r = (l + r) / 2;
      } else {
        l = (l + r) / 2;
      }
    }
    d[i] = (((long long)arr[l]) * k == (long long)(arr[i])) ? (d[l] + 1) : 1;
    if (d[i] % 2) ans++;
  }
  printf("%d", ans);
  return 0;
}
