#include <bits/stdc++.h>
using namespace std;
void fun() {
  long long n, x, y, ans = 0, b, i, j, k, f;
  cin >> n >> k;
  long long a[n];
  map<long long, long long> m;
  for (i = 0; i < n; i++) {
    cin >> a[i];
    m[a[i]]++;
  }
  if (k == 1) {
    cout << n << endl;
    return;
  }
  for (i = 0; i < n; i++) {
    if (m[k * a[i]] > 0)
      ans++;
    else {
      x = 0;
      for (j = 1; j != -1; j++) {
        f = pow(k, j);
        if (a[i] % f != 0)
          break;
        else if (m[a[i] / f] > 0) {
          x++;
        } else
          break;
      }
      if (j == 1 || j == 0 || j == 2) continue;
      ans -= (j - 1);
      ans += j / 2;
    }
  }
  cout << n - ans << endl;
}
int main() { fun(); }
