#include <bits/stdc++.h>
using namespace std;
map<int, int> m;
int n, k;
int a[100000 + 5];
bool b[100000 + 5];
int main() {
  scanf("%d%d", &n, &k);
  if (k == 1) {
    printf("%d\n", n);
    return 0;
  }
  for (int i = 0; i < n; ++i) scanf("%d", a + i);
  sort(a, a + n);
  for (int i = 0; i < n; ++i) m[a[i]] = i;
  int ans = 0;
  for (int i = 0; i < n; ++i)
    if (!b[m[a[i]]]) {
      int cnt = 0;
      for (long long j = (long long)a[i]; j <= 1000000000; j *= k) {
        if (m.find(j) != m.end()) {
          ++cnt;
          b[m[j]] = true;
        } else
          break;
      }
      ans += ceil((cnt * 1.0 / 2));
    }
  printf("%d\n", ans);
}
