#include <bits/stdc++.h>
using namespace std;
int returnDiv(unordered_map<int, int> &MAP, int x, int k) {
  if (MAP[x] == -1)
    return 0;
  else if (x < k || x % k != 0) {
    MAP[x] = -1;
    return 1;
  } else if (MAP.find(x / k) == MAP.end()) {
    MAP[x] = -1;
    return 1;
  } else {
    MAP[x] = -1;
    return 1 + returnDiv(MAP, x / k, k);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, k;
  cin >> n >> k;
  vector<int> ARR(n);
  unordered_map<int, int> MAP;
  for (int &x : ARR) {
    cin >> x;
    MAP[x] = 1;
  }
  int count = 0;
  sort(ARR.begin(), ARR.end(), [](int a, int b) { return a > b; });
  for (int i = 0; i < n; ++i) {
    int countCurr = returnDiv(MAP, ARR[i], k);
    if (countCurr > 0 && (countCurr & 1)) {
      ++countCurr;
    }
    count += countCurr / 2;
  }
  cout << count << '\n';
}
