#include <bits/stdc++.h>
using namespace std;

#define _p(...) (void)printf(__VA_ARGS__)
#define forr(x,arr) for(auto&& x:arr)
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) _rep3(i,0,n)
#define _rep3(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2,)(__VA_ARGS__)
#define _rrep2(i,n) _rrep3(i,0,n)
#define _rrep3(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2,)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
#define bit(n) (1LL<<(n))
#define sz(x) ((int)(x).size())
#define fst first
#define snd second
using ll=long long;using pii=pair<int,int>;using vb=vector<bool>;
using vi=vector<int>;using vvi=vector<vi>;using vvvi=vector<vvi>;
using vl=vector<ll>;using vvl=vector<vl>;using vvvl=vector<vvl>;
using vd=vector<double>;using vvd=vector<vd>;using vvvd=vector<vvd>;
using vpii=vector<pii>;using vvpii=vector<vpii>;using vvvpii=vector<vvpii>;
template <typename T> T read() {T t; cin >> t; return t;}

void Main() {
  int n = read<int>();
  int m = read<int>();

  map<int, int> X;
  vi S(m);

  rep(i, n) {
    int x = read<int>();
    X[x]++;
    S[x%m]++;
  }

  int ans = 0;

  vector<vector<map<int, int>>> M2(m, vector<map<int, int>>(2));

  int zc = 0;
  int hc = 0;

  forr(xc, X) {
    int x = xc.fst;
    int c = xc.snd;
    if (c == 0) continue;

    if (x % m == 0) {
      zc += c;
    }
    else {
      if ((x % m) * 2 == m) hc += c;
      else M2[x%m][c%2][x] += c;
    }
  }

  ans += zc / 2;
  ans += hc / 2;

  rep(mo, 1, m) {
    int ta = m - mo;

    int sz1 = sz(M2[mo][1]);
    int sz2 = S[ta];

    int can = min(sz1, sz2);
    ans += can;
    S[mo] -= can;
    S[ta] -= can;

    /*
    cout<<"=========="<<endl;
    cout<<"mo: "<<mo<<endl;
    cout<<"ta: "<<ta<<endl;
    cout<<"sz1: "<<sz1<<endl;
    cout<<"sz2: "<<sz2<<endl;
    cout<<"can: "<<can<<endl;
    */

    {
      int a = 0;
      vi er;
      forr(xc, M2[mo][1]) {
        if (a++ == can) break;
        int x = xc.fst;
        int c = xc.snd;
        //cout<<"!!x: "<<x<<endl;
        if (c > 1) M2[mo][0][x] = c - 1;
        er.push_back(x);
      }
      forr(e, er) {
        M2[mo][1].erase(e);
      }
    }

    {
      int a = 0;
      while (a++ < can) {
        if (sz(M2[ta][1])) {
          auto xc = M2[ta][1].begin();
          int x = xc->fst;
          int c = xc->snd;
          if (c > 1) M2[ta][0][x] = c - 1;
          M2[ta][1].erase(x);
        }
        else {
          auto xc = M2[ta][0].begin();
          int x = xc->fst;
          //cout<<"?! x: "<<x<<endl;
          int c = xc->snd;
          if (c > 1) M2[ta][1][x] = c - 1;
          M2[ta][0].erase(x);
        }
      }
    }
  }

  //cout<<"ans: "<<ans<<endl;

  rep(mo, m) {
    rep(o, 2) {
      forr(xc, M2[mo][o]) {
        int x = xc.fst;
        int c = xc.snd;
        //cout<<"x: "<<x<<endl;
        //cout<<"c: "<<c<<endl;
        ans += c / 2;
      }
    }
  }
  cout << ans << endl;
}
int main() { cin.tie(nullptr); ios::sync_with_stdio(false); Main(); return 0; }

### Prompt

Generate 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 <bits/stdc++.h>
using namespace std;

#define _p(...) (void)printf(__VA_ARGS__)
#define forr(x,arr) for(auto&& x:arr)
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) _rep3(i,0,n)
#define _rep3(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2,)(__VA_ARGS__)
#define _rrep2(i,n) _rrep3(i,0,n)
#define _rrep3(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2,)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
#define bit(n) (1LL<<(n))
#define sz(x) ((int)(x).size())
#define fst first
#define snd second
using ll=long long;using pii=pair<int,int>;using vb=vector<bool>;
using vi=vector<int>;using vvi=vector<vi>;using vvvi=vector<vvi>;
using vl=vector<ll>;using vvl=vector<vl>;using vvvl=vector<vvl>;
using vd=vector<double>;using vvd=vector<vd>;using vvvd=vector<vvd>;
using vpii=vector<pii>;using vvpii=vector<vpii>;using vvvpii=vector<vvpii>;
template <typename T> T read() {T t; cin >> t; return t;}

void Main() {
  int n = read<int>();
  int m = read<int>();

  map<int, int> X;
  vi S(m);

  rep(i, n) {
    int x = read<int>();
    X[x]++;
    S[x%m]++;
  }

  int ans = 0;

  vector<vector<map<int, int>>> M2(m, vector<map<int, int>>(2));

  int zc = 0;
  int hc = 0;

  forr(xc, X) {
    int x = xc.fst;
    int c = xc.snd;
    if (c == 0) continue;

    if (x % m == 0) {
      zc += c;
    }
    else {
      if ((x % m) * 2 == m) hc += c;
      else M2[x%m][c%2][x] += c;
    }
  }

  ans += zc / 2;
  ans += hc / 2;

  rep(mo, 1, m) {
    int ta = m - mo;

    int sz1 = sz(M2[mo][1]);
    int sz2 = S[ta];

    int can = min(sz1, sz2);
    ans += can;
    S[mo] -= can;
    S[ta] -= can;

    /*
    cout<<"=========="<<endl;
    cout<<"mo: "<<mo<<endl;
    cout<<"ta: "<<ta<<endl;
    cout<<"sz1: "<<sz1<<endl;
    cout<<"sz2: "<<sz2<<endl;
    cout<<"can: "<<can<<endl;
    */

    {
      int a = 0;
      vi er;
      forr(xc, M2[mo][1]) {
        if (a++ == can) break;
        int x = xc.fst;
        int c = xc.snd;
        //cout<<"!!x: "<<x<<endl;
        if (c > 1) M2[mo][0][x] = c - 1;
        er.push_back(x);
      }
      forr(e, er) {
        M2[mo][1].erase(e);
      }
    }

    {
      int a = 0;
      while (a++ < can) {
        if (sz(M2[ta][1])) {
          auto xc = M2[ta][1].begin();
          int x = xc->fst;
          int c = xc->snd;
          if (c > 1) M2[ta][0][x] = c - 1;
          M2[ta][1].erase(x);
        }
        else {
          auto xc = M2[ta][0].begin();
          int x = xc->fst;
          //cout<<"?! x: "<<x<<endl;
          int c = xc->snd;
          if (c > 1) M2[ta][1][x] = c - 1;
          M2[ta][0].erase(x);
        }
      }
    }
  }

  //cout<<"ans: "<<ans<<endl;

  rep(mo, m) {
    rep(o, 2) {
      forr(xc, M2[mo][o]) {
        int x = xc.fst;
        int c = xc.snd;
        //cout<<"x: "<<x<<endl;
        //cout<<"c: "<<c<<endl;
        ans += c / 2;
      }
    }
  }
  cout << ans << endl;
}
int main() { cin.tie(nullptr); ios::sync_with_stdio(false); Main(); return 0; }

```