#include <bits/stdc++.h>
using namespace std;
map<long long, bool> mp;
map<long long, bool> if_calculated;
int main() {
  int n;
  long long k;
  cin >> n >> k;
  for (int i = 0; i < n; ++i) {
    int t;
    cin >> t;
    mp[t] = 1;
  }
  int ans = 0;
  if (k == 1)
    ans = n;
  else
    for (auto i : mp) {
      long long pos = i.first;
      int num = 0;
      while (mp[pos]) {
        mp[pos] = 0;
        num++;
        pos *= k;
      }
      ans += ((num + 1) >> 1);
    }
  cout << ans << endl;
}
