#include <bits/stdc++.h>
using namespace std;
int a[100005];
int has[100005];
int main() {
  int n, k, i, ans;
  while (~scanf("%d%d", &n, &k)) {
    memset(has, 0, sizeof(has));
    for (i = 0; i < n; i++) scanf("%d", &a[i]);
    sort(a, a + n);
    ans = 0;
    for (i = 0; i < n; i++) {
      if (has[i]) continue;
      long long key = a[i];
      int tp = 0, flg = 1;
      int l = i + 1, r = n, mid;
      while (flg) {
        ++tp;
        flg = 0;
        r = n;
        long long tp = (long long)key * k;
        if (tp > 1000000000) break;
        while (l < r) {
          mid = (l + r) / 2;
          if (a[mid] == tp) {
            l = mid + 1;
            flg = 1;
            has[mid] = 1;
            break;
          }
          if (a[mid] > tp)
            r = mid;
          else
            l = mid + 1;
        }
        key = tp;
      }
      ans += (tp + 1) / 2;
    }
    cout << ans << endl;
  }
  return 0;
}
