#include <bits/stdc++.h>
using namespace std;
long long inp[100003], ans = 0;
map<long long, long long> vis;
map<long long, bool> used;
int main() {
  long long n, k;
  cin >> n >> k;
  for (int i = 0; i < n; i++) cin >> inp[i];
  sort(inp, inp + n);
  for (int i = n - 1; i >= 0; i--) {
    vis[inp[i]]++;
    if (!used[inp[i] * k])
      ans++, used[inp[i]] = true;
    else if (vis[inp[i]] - 1 == vis[inp[i] * k])
      ans += vis[inp[i]], ans -= vis[inp[i] * k], used[inp[i]] = true,
                                                  used[inp[i] * k] = false;
    else if (vis[inp[i]] - 1 > vis[inp[i] * k])
      ans++;
  }
  cout << ans << endl;
}
