#include <iostream>
#include <sstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>

using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

#define pb push_back
#define mp make_pair
#define mt make_tuple

int get_pair_num(const vector<int>& v) {
    // v is sorted
    int prev = -1;
    int ans = 0;
    for(auto e: v) {
        if (e == prev) {
            ++ans;
            prev = -1;
        }
        else {
            prev = e;
        }
    }
    return ans;
}

int main(void)
{
    cin.sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    vector<int> Xs(N);
    REP(n,N) {
        cin >> Xs[n];
    }
    sort(ALL(Xs));


    vector<vector<int>> nums(M);
    REP(n,N) {
        int x = Xs[n];
        nums[x % M].pb(x);
    }

    ll ans = 0;
    REP(m, M / 2 + 1) {
        if (m == 0 || m * 2 == M) {
            ans += SIZE(nums[m]) / 2;
        }
        else {
            int n = M - m;
            auto size_m = SIZE(nums[m]);
            auto size_n = SIZE(nums[n]);
            ans += min(size_m, size_n);
            int pair_num = (size_m < size_n) ?
                get_pair_num(nums[n]) : 
                get_pair_num(nums[m]);
            ans += min(abs(size_m - size_n) / 2,
                       pair_num);
        }
    }
    cout << ans << endl;

    return 0;
}

### 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 <sstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>

using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

#define pb push_back
#define mp make_pair
#define mt make_tuple

int get_pair_num(const vector<int>& v) {
    // v is sorted
    int prev = -1;
    int ans = 0;
    for(auto e: v) {
        if (e == prev) {
            ++ans;
            prev = -1;
        }
        else {
            prev = e;
        }
    }
    return ans;
}

int main(void)
{
    cin.sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    vector<int> Xs(N);
    REP(n,N) {
        cin >> Xs[n];
    }
    sort(ALL(Xs));


    vector<vector<int>> nums(M);
    REP(n,N) {
        int x = Xs[n];
        nums[x % M].pb(x);
    }

    ll ans = 0;
    REP(m, M / 2 + 1) {
        if (m == 0 || m * 2 == M) {
            ans += SIZE(nums[m]) / 2;
        }
        else {
            int n = M - m;
            auto size_m = SIZE(nums[m]);
            auto size_n = SIZE(nums[n]);
            ans += min(size_m, size_n);
            int pair_num = (size_m < size_n) ?
                get_pair_num(nums[n]) : 
                get_pair_num(nums[m]);
            ans += min(abs(size_m - size_n) / 2,
                       pair_num);
        }
    }
    cout << ans << endl;

    return 0;
}

```