#include <bits/stdc++.h>
using namespace std;
ifstream Cin("input.txt");
ofstream Cout("output.txt");
int main() {
  long long n, m, k, i, j, tmp, cur, ans = 0;
  cin >> n >> k;
  vector<long long> r(n), zz(n), ff;
  map<long long, long long> nm;
  for (i = 0; i < n; i++) cin >> r[i];
  sort(r.begin(), r.end());
  for (i = 0; i < n; i++) nm[r[i]]++;
  if (k == 1) {
    tmp = 1;
    for (i = 1; i < n; i++)
      if (r[i] != r[i - 1]) tmp++;
    cout << tmp;
    return 0;
  }
  for (i = 0; i < n; i++) {
    zz[i] = r[i];
    while (zz[i] % k == 0) zz[i] /= k;
  }
  sort(zz.begin(), zz.end());
  ff.push_back(zz[0]);
  for (i = 1; i < n; i++)
    if (zz[i] != zz[i - 1]) ff.push_back(zz[i]);
  m = (long long)ff.size();
  for (i = 0; i < m; i++) {
    vector<long long> dp;
    tmp = ff[i];
    dp.push_back(nm[tmp]);
    while (tmp * k <= 1000000000) tmp *= k, dp.push_back(nm[tmp]);
    long long l = (long long)dp.size();
    vector<long long> ddp(l);
    ddp[0] = cur = dp[0];
    if (l > 1) ddp[1] = dp[1], cur = max(cur, ddp[1]);
    if (l > 2) ddp[2] = dp[2] + dp[0], cur = max(cur, ddp[2]);
    for (j = 3; j < l; j++)
      ddp[j] = dp[j] + max(ddp[j - 2], ddp[j - 3]), cur = max(cur, ddp[j]);
    ans += cur;
  }
  cout << ans;
}

### Prompt

Your task is to create a CPP solution to the following problem:

A k-multiple free set is a set of integers where there is no pair of integers where one is equal to another integer multiplied by k. That is, there are no two integers x and y (x < y) from the set, such that y = x·k.

You're given a set of n distinct positive integers. Your task is to find the size of it's largest k-multiple free subset.

Input

The first line of the input contains two integers n and k (1 ≤ n ≤ 105, 1 ≤ k ≤ 109). The next line contains a list of n distinct positive integers a1, a2, ..., an (1 ≤ ai ≤ 109).

All the numbers in the lines are separated by single spaces.

Output

On the only line of the output print the size of the largest k-multiple free subset of {a1, a2, ..., an}.

Examples

Input

6 2
2 3 6 5 4 10


Output

3

Note

In the sample input one of the possible maximum 2-multiple free subsets is {4, 5, 6}.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
ifstream Cin("input.txt");
ofstream Cout("output.txt");
int main() {
  long long n, m, k, i, j, tmp, cur, ans = 0;
  cin >> n >> k;
  vector<long long> r(n), zz(n), ff;
  map<long long, long long> nm;
  for (i = 0; i < n; i++) cin >> r[i];
  sort(r.begin(), r.end());
  for (i = 0; i < n; i++) nm[r[i]]++;
  if (k == 1) {
    tmp = 1;
    for (i = 1; i < n; i++)
      if (r[i] != r[i - 1]) tmp++;
    cout << tmp;
    return 0;
  }
  for (i = 0; i < n; i++) {
    zz[i] = r[i];
    while (zz[i] % k == 0) zz[i] /= k;
  }
  sort(zz.begin(), zz.end());
  ff.push_back(zz[0]);
  for (i = 1; i < n; i++)
    if (zz[i] != zz[i - 1]) ff.push_back(zz[i]);
  m = (long long)ff.size();
  for (i = 0; i < m; i++) {
    vector<long long> dp;
    tmp = ff[i];
    dp.push_back(nm[tmp]);
    while (tmp * k <= 1000000000) tmp *= k, dp.push_back(nm[tmp]);
    long long l = (long long)dp.size();
    vector<long long> ddp(l);
    ddp[0] = cur = dp[0];
    if (l > 1) ddp[1] = dp[1], cur = max(cur, ddp[1]);
    if (l > 2) ddp[2] = dp[2] + dp[0], cur = max(cur, ddp[2]);
    for (j = 3; j < l; j++)
      ddp[j] = dp[j] + max(ddp[j - 2], ddp[j - 3]), cur = max(cur, ddp[j]);
    ans += cur;
  }
  cout << ans;
}

```