#include <bits/stdc++.h>
using namespace std;
void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }
template <typename T, typename V>
void __print(const pair<T, V> &x) {
  cerr << '{';
  __print(x.first);
  cerr << ',';
  __print(x.second);
  cerr << '}';
}
template <typename T>
void __print(const T &x) {
  int f = 0;
  cerr << '{';
  for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
  cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
  __print(t);
  if (sizeof...(v)) cerr << ", ";
  _print(v...);
}
const long double PI = acos(-1.0);
bool AreSame(long double a, long double b) { return fabs(a - b) < 1e-9; }
long long int power(long long int x, long long int y) {
  long long int res = 1;
  x = x;
  while (y > 0) {
    if (y & 1) res = (res * x);
    y = y >> 1;
    x = (x * x);
  }
  return res;
}
long long int power(long long int x, long long int y, long long int p) {
  long long int res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
long long int gcd(long long int a, long long int b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
long long int ceil2(long long int a, long long int b) {
  long long int c = a / b;
  if (a % b) c++;
  return c;
}
bool isPalindrome(string s) {
  string t = s;
  reverse(t.begin(), t.end());
  return s == t;
}
vector<long long int> vec[100010];
long long int arr[100010];
bool visited[100010];
set<long long int> s;
map<long long int, long long int> mm;
long long int curr = 0;
long long int n, k;
void fx(long long int key) {
  vec[curr].push_back(key);
  mm[key] = 0;
  s.erase(key);
  if (s.count(key * k)) fx(key * k);
}
void solve() {
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    mm[arr[i]]++;
    s.insert(arr[i]);
  }
  sort(arr, arr + n);
  if (k == 1) {
    cout << s.size() << "\n";
    return;
  }
  for (int i = 0; i < n; i++) {
    if (mm[arr[i]]) {
      fx(arr[i]);
      curr++;
    }
  }
  long long int res = 0;
  for (int i = 0; i < curr; i++) {
    ;
    res = res + vec[i].size() / 2 + vec[i].size() % 2;
  }
  cout << res << "\n";
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  long long int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
