#include <bits/stdc++.h>
using namespace std;
map<long long int, int> mp;
long long int arr[100005], par[100005];
int main() {
  ios_base::sync_with_stdio(0);
  long long int i, j, n, m, k, l;
  cin >> n >> k;
  for (i = 1; i <= n; i++) {
    cin >> arr[i];
  }
  sort(arr + 1, arr + 1 + n);
  for (i = 1; i <= n; i++) {
    mp[arr[i]] = i;
    par[i] = i;
  }
  for (i = n; i >= 1; i--) {
    if (arr[i] % k == 0) {
      if (mp[arr[i] / k] != 0) {
        par[i] = mp[arr[i] / k];
      }
    }
  }
  int ans = 0;
  for (i = n; i > 0; i--) {
    if (par[i] != 0) {
      int cnt = 1;
      j = i;
      while (par[j] != j) {
        cnt++;
        l = par[j];
        par[j] = 0;
        j = l;
      }
      par[j] = 0;
      ans = ans + (cnt / 2) + (cnt % 2);
    }
  }
  cout << ans << "\n";
  return 0;
}
