#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <random> // random_device rd; mt19937 mt(rd());
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.
// insert #if<tab> by my emacs. #if DEBUG == 1 ... #end

typedef long long ll;

// const int dx[4] = {1, 0, -1, 0};
// const int dy[4] = {0, 1, 0, -1};

// const int C = 1e6+10;
// const ll M = 1000000007;

int N, M;
int X[100010];
int cnt[100010];
int mod[100010][2];

int get_cnt(int x) {
  return mod[x][0] + 2 * mod[x][1];
}

int same(int x) {
  int c = get_cnt(x);
  return c/2;
}

int odd(int x) {
  int c = get_cnt(x);
  int d = get_cnt(M - x);
  if (c < d) {
    swap(c, d);
    x = M - x;
  }
  int ans = d;
  if (d <= mod[x][0]) {
    ans += mod[x][1];
    return ans;
  } else {
    ans += (mod[x][1] * 2 - (d - mod[x][0]))/2;
    return ans;
  }
}

int res(int x) {
  if (M%2 == 0 && x == M/2) {
    return same(x);
  } else if (x == 0) {
    return same(x);
  } else {
    return odd(x);
  }
}

int main () {
  cin >> N >> M;
  for (auto i = 0; i < N; ++i) {
    cin >> X[i];
  }
  fill(cnt, cnt+100010, 0);
  for (auto i = 0; i < N; ++i) {
    cnt[X[i]]++;
  }
  fill(&mod[0][0], &mod[0][0]+100010*2, 0);
  for (auto i = 0; i < 100010; ++i) {
    mod[i%M][0] += cnt[i]%2;
    mod[i%M][1] += cnt[i]/2;
  }
  int ans = 0;
  for (auto i = 0; i <= M/2; ++i) {
    ans += res(i);
  }
  cout << ans << endl;
}

### Prompt

Your challenge is to write a Cpp solution to the following problem:

Takahashi is playing with N cards.

The i-th card has an integer X_i on it.

Takahashi is trying to create as many pairs of cards as possible satisfying one of the following conditions:

* The integers on the two cards are the same.
* The sum of the integers on the two cards is a multiple of M.



Find the maximum number of pairs that can be created.

Note that a card cannot be used in more than one pair.

Constraints

* 2≦N≦10^5
* 1≦M≦10^5
* 1≦X_i≦10^5

Input

The input is given from Standard Input in the following format:


N M
X_1 X_2 ... X_N


Output

Print the maximum number of pairs that can be created.

Examples

Input

7 5
3 1 4 1 5 9 2


Output

3


Input

15 10
1 5 6 10 11 11 11 20 21 25 25 26 99 99 99


Output

6

### Response

```cpp
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <random> // random_device rd; mt19937 mt(rd());
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.
// insert #if<tab> by my emacs. #if DEBUG == 1 ... #end

typedef long long ll;

// const int dx[4] = {1, 0, -1, 0};
// const int dy[4] = {0, 1, 0, -1};

// const int C = 1e6+10;
// const ll M = 1000000007;

int N, M;
int X[100010];
int cnt[100010];
int mod[100010][2];

int get_cnt(int x) {
  return mod[x][0] + 2 * mod[x][1];
}

int same(int x) {
  int c = get_cnt(x);
  return c/2;
}

int odd(int x) {
  int c = get_cnt(x);
  int d = get_cnt(M - x);
  if (c < d) {
    swap(c, d);
    x = M - x;
  }
  int ans = d;
  if (d <= mod[x][0]) {
    ans += mod[x][1];
    return ans;
  } else {
    ans += (mod[x][1] * 2 - (d - mod[x][0]))/2;
    return ans;
  }
}

int res(int x) {
  if (M%2 == 0 && x == M/2) {
    return same(x);
  } else if (x == 0) {
    return same(x);
  } else {
    return odd(x);
  }
}

int main () {
  cin >> N >> M;
  for (auto i = 0; i < N; ++i) {
    cin >> X[i];
  }
  fill(cnt, cnt+100010, 0);
  for (auto i = 0; i < N; ++i) {
    cnt[X[i]]++;
  }
  fill(&mod[0][0], &mod[0][0]+100010*2, 0);
  for (auto i = 0; i < 100010; ++i) {
    mod[i%M][0] += cnt[i]%2;
    mod[i%M][1] += cnt[i]/2;
  }
  int ans = 0;
  for (auto i = 0; i <= M/2; ++i) {
    ans += res(i);
  }
  cout << ans << endl;
}

```