#include <bits/stdc++.h>
using namespace std;
int n, k;
int compare(const void *a, const void *b) {
  long long ina = *(long long *)a;
  long long inb = *(long long *)b;
  if (ina > inb) return 1;
  if (ina < inb) return -1;
  return 0;
}
void msort(long long *in, int start, int end) {
  long long buff[100000];
  if (start + 1 >= end) return;
  msort(in, start, (start + end) / 2);
  msort(in, (start + end) / 2, end);
  int p1 = start;
  int p2 = (start + end) / 2;
  int cur = start;
  while (p1 < (start + end) / 2 || p2 < end) {
    if (p1 == (start + end) / 2) {
      buff[cur++] = in[p2++];
      continue;
    }
    if (p2 == end) {
      buff[cur++] = in[p1++];
      continue;
    }
    if (in[p1] > in[p2]) {
      buff[cur++] = in[p2++];
      continue;
    } else {
      buff[cur++] = in[p1++];
      continue;
    }
  }
  for (int i = start; i < end; i++) in[i] = buff[i];
}
int main() {
  cin >> n >> k;
  long long data[100000];
  for (int i = 0; i < n; i++) {
    long long in;
    cin >> in;
    long long times = 0;
    while (k > 1 && in % k == 0) {
      in /= k;
      times++;
    }
    data[i] = (in * (1LL << 32) + times);
  }
  msort(data, 0, n);
  int num = 0;
  int skip = 0;
  for (int i = 0; i < n; i++) {
    if (i == 0) {
      num++;
      continue;
    }
    if (skip == 1) {
      num++;
      skip = 0;
      continue;
    }
    if (data[i] - data[i - 1] == 1) {
      skip = 1;
      continue;
    }
    num++;
  }
  cout << num << "\n";
}
