#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <chrono>
#include <random>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

int N, M;
VI x;
LL ans = 0;

int main(void) {
    scanf("%d%d", &N, &M);
    x.resize(N);
    for_each(ALL(x), [](int &e){scanf("%d", &e);});
    VVI modset(M);
    VI modcnt(M);
    FORE(e, x) {
        modset[e % M].EB(e);
    }
    REP(i, M) {
        modcnt[i] = modset.size();
        SORT(modset[i]);
    }
    FOR(i, 1, ((M - 1) / 2) + 1) {
        if (M % 2 == 0 && i == M / 2) continue;
        int buf = min(modset[i].size(), modset[M - i].size());
        ans += buf;
        modcnt[i] = modcnt[M - i] = buf;
    }
    if (M % 2 == 0) {
        int buf = modset[M / 2].size() / 2;
        modcnt[M / 2] = buf * 2;
        ans += buf;
    }
    int buf = modset[0].size() / 2;
    modcnt[0] = buf * 2;
    ans += buf;
    REP(i, M) {
        int cnt = 0;
        int pre = -1;
        int ok = (int)modset[i].size() - modcnt[i];
        FORE(e, modset[i]) {
            assert(ok >= cnt);
            if (ok - cnt <= 1) break;
            if (pre == e) {
                ans++;
                pre = -1;
                cnt += 2;
            } else {
                pre = e;
            }
        }
    }
    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 <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <chrono>
#include <random>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

int N, M;
VI x;
LL ans = 0;

int main(void) {
    scanf("%d%d", &N, &M);
    x.resize(N);
    for_each(ALL(x), [](int &e){scanf("%d", &e);});
    VVI modset(M);
    VI modcnt(M);
    FORE(e, x) {
        modset[e % M].EB(e);
    }
    REP(i, M) {
        modcnt[i] = modset.size();
        SORT(modset[i]);
    }
    FOR(i, 1, ((M - 1) / 2) + 1) {
        if (M % 2 == 0 && i == M / 2) continue;
        int buf = min(modset[i].size(), modset[M - i].size());
        ans += buf;
        modcnt[i] = modcnt[M - i] = buf;
    }
    if (M % 2 == 0) {
        int buf = modset[M / 2].size() / 2;
        modcnt[M / 2] = buf * 2;
        ans += buf;
    }
    int buf = modset[0].size() / 2;
    modcnt[0] = buf * 2;
    ans += buf;
    REP(i, M) {
        int cnt = 0;
        int pre = -1;
        int ok = (int)modset[i].size() - modcnt[i];
        FORE(e, modset[i]) {
            assert(ok >= cnt);
            if (ok - cnt <= 1) break;
            if (pre == e) {
                ans++;
                pre = -1;
                cnt += 2;
            } else {
                pre = e;
            }
        }
    }
    cout << ans << endl;
}

```