#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  if (k == 1) {
    cout << n << endl;
    return 0;
  }
  set<int> s;
  int x;
  for (int i = 0; i < n; i++) {
    cin >> x;
    s.insert(x);
  }
  int res = 0;
  while (!s.empty()) {
    int x = *s.begin();
    int t = 0;
    while (s.size() && s.count(x)) {
      ++t;
      s.erase(x);
      if (1LL * x * k > (int)1e9) break;
      x = x * k;
    }
    res += (t + 1) / 2;
  }
  cout << res << endl;
  return 0;
}
