#include <bits/stdc++.h>
using namespace std;
const int Mx = 100010;
int num[Mx], cnt[Mx];
long long a[Mx];
int cmp(const void *a, const void *b) { return *(int *)a - *(int *)b; }
bool vis[Mx];
int m, k;
int dp[Mx];
int jump(int s, long long x) {
  int ret = -1;
  int low = s + 1, up = m;
  while (low <= up) {
    int mid = (low + up) >> 1;
    if (a[mid] < x) {
      low = mid + 1;
    } else if (a[mid] > x) {
      up = mid - 1;
    } else {
      return mid;
    }
  }
  return ret;
}
int path[Mx];
int getNum(int x) {
  if (x == -1)
    return 0;
  else
    return dp[x];
}
int getAns(int pos) {
  int pre = -1;
  while (pos != -1) {
    if (pre != -1)
      dp[pos] = max(getNum(pre), getNum(path[pre]) + cnt[pos]);
    else
      dp[pos] = cnt[pos];
    path[pos] = pre;
    pre = pos;
    vis[pos] = true;
    pos = jump(pos, a[pos] * k);
  }
  return dp[pre];
}
int main() {
  int i, n;
  while (~scanf("%d%d", &n, &k)) {
    for (i = 0; i < n; ++i) {
      scanf("%d", &num[i]);
    }
    qsort(num, n, sizeof(num[0]), cmp);
    m = 0;
    a[0] = num[0];
    memset(vis, 0, sizeof(vis));
    memset(cnt, 0, sizeof(cnt));
    memset(dp, 0, sizeof(dp));
    cnt[0] = 1;
    for (i = 1; i < n; ++i) {
      if (num[i] == num[i - 1]) {
        ++cnt[m];
        continue;
      }
      a[++m] = num[i];
      ++cnt[m];
    }
    if (k == 1) {
      printf("%d\n", m + 1);
      continue;
    }
    int ans = 0;
    for (i = 0; i <= m; ++i) {
      if (!vis[i]) {
        ans += getAns(i);
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}
