#include <bits/stdc++.h>
using namespace std;
vector<char> used, incl;
vector<vector<int>> g;
vector<long long> v;
int bins(int l, int r, long long val) {
  while (l < r - 1) {
    int m = (l + r) / 2;
    if (v[m] > val) {
      r = m;
      continue;
    }
    if (v[m] < val) {
      l = m + 1;
      continue;
    }
    if (v[m] == val) {
      return m;
    }
  }
  if (l < v.size() && v[l] == val)
    return l;
  else
    return -1;
}
int bfs(int v) {
  queue<int> q;
  q.push(v);
  int ans = 0, count = 0;
  used[v] = true;
  while (!q.empty()) {
    int cur = q.front();
    q.pop();
    count++;
    int n = g[cur].size();
    for (int i = 0; i < n; i++) {
      int to = g[cur][i];
      if (!used[to]) {
        used[to] = true;
        if (incl[cur] == false) {
          incl[to] = true;
          ans++;
        } else {
          incl[to] = false;
        }
        q.push(to);
      }
    }
  }
  return max(ans, count - ans);
}
int main() {
  long long n, k;
  cin >> n >> k;
  v.resize(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  g.resize(n);
  sort(v.begin(), v.end());
  for (int i = 0; i < n; i++) {
    int y = bins(0, n, v[i] * k);
    if (y != -1) {
      g[i].push_back(y);
      g[y].push_back(i);
    }
  }
  used.resize(n);
  incl.resize(n);
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (!used[i]) {
      ans += bfs(i);
    }
  }
  cout << ans;
  return 0;
}
