#include <bits/stdc++.h>
using namespace std;
template <class T>
T inline Abs(const T& x) {
  return x < 0 ? -x : x;
}
template <class T>
T inline Sqr(const T& x) {
  return x * x;
}
int main(int argc, char* argv[]) {
  ios_base::sync_with_stdio(false);
  long long n, k;
  cin >> n >> k;
  vector<long long> a(n);
  vector<bool> b(n, false);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  int ans = 0;
  for (int i = 0; i < n; ++i)
    if (!b[i]) {
      b[i] = true;
      if (k == 1) {
        ++ans;
        continue;
      }
      long long cur = a[i];
      int cnt = 1;
      while (cur * k <= a[n - 1] &&
             binary_search(a.begin(), a.end(), cur * k)) {
        int ind = lower_bound(a.begin(), a.end(), cur * k) - a.begin();
        b[ind] = true;
        cur *= k;
        ++cnt;
      }
      ans += (cnt + 1) / 2;
    }
  cout << ans << endl;
  return 0;
}
