#include <bits/stdc++.h>
using namespace std;
long long M = 1e9 + 7, N = 205001;
long long mm(long long x, long long y) {
  x %= M, y %= M;
  return (x * y) % M;
}
long long po(long long x, long long y) {
  if (!y) return 1;
  long long a = po(x, y / 2) % M;
  if (y % 2) return mm(a, mm(a, x));
  return mm(a, a);
}
void solve() {
  long long n, k, ans = 0, x;
  cin >> n >> k;
  set<long long> s;
  map<long long, long long> mp;
  for (long long i = 0; 0 < n ? i < n : i > n; 0 < n ? i += 1 : i -= 1) {
    cin >> x;
    s.insert(x);
  }
  while (!s.empty()) {
    long long p = *(s.begin());
    long long t = 1;
    while (s.count(p)) {
      t++;
      s.erase(p);
      p *= k;
    }
    ans += (t / 2);
  }
  cout << ans;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  while (t--) solve();
  return 0;
}
