#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N, M;
vector<int> A[MAX_N];

int pre(const vi& vec) {
	int res = sz(vec);
	int prev = -1;
	rep(i, 0, sz(vec)) {
		if(prev == -1) prev = vec[i];
		else if(prev == vec[i]) {
			res -= 2; prev = -1;
		}
		else {
			prev = vec[i];
		}
	}
	return res;
}

void solve() {
	cin >> N >> M;
	rep(i, 0, N) {
		int b;
		cin >> b;
		A[b % M].pb(b);
	}
	rep(i, 0, M) {
		sort(all(A[i]));
	}
	int res = 0;
	rep(i, 0, M) {
		vi& vec1 = A[i];
		vi& vec2 = A[(M - i) % M];
		int n1 = sz(vec1), n2 = sz(vec2);
		int v1 = pre(vec1), v2 = pre(vec2);
		if(i == 0) {
			res += (n1 / 2) * 2;
			continue;
		}
		else if(M % 2 == 0 && i == M / 2) {
			res += (n1 / 2) * 2;
			continue;
		}
		if(n1 > n2) {
			swap(n1, n2); swap(v1, v2);
		}
		// debug(v1, n1, v2, n2);
		int tmp;
		if((n1 + n2) % 2 == 0) {
			if(v2 <= n1) {
				tmp = (n1 + n2) / 2;
			}
			else {
				tmp = n1 + (n2 - v2) / 2;
			}
		}
		else {
			if(v2 <= n1 + 1) {
				tmp = (n1 + n2) / 2;
			}
			else {
				tmp = n1 + (n2 - v2) / 2;
			}
		}
		res += tmp;
	}
	cout << res / 2 << "\n";
}
int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	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 <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N, M;
vector<int> A[MAX_N];

int pre(const vi& vec) {
	int res = sz(vec);
	int prev = -1;
	rep(i, 0, sz(vec)) {
		if(prev == -1) prev = vec[i];
		else if(prev == vec[i]) {
			res -= 2; prev = -1;
		}
		else {
			prev = vec[i];
		}
	}
	return res;
}

void solve() {
	cin >> N >> M;
	rep(i, 0, N) {
		int b;
		cin >> b;
		A[b % M].pb(b);
	}
	rep(i, 0, M) {
		sort(all(A[i]));
	}
	int res = 0;
	rep(i, 0, M) {
		vi& vec1 = A[i];
		vi& vec2 = A[(M - i) % M];
		int n1 = sz(vec1), n2 = sz(vec2);
		int v1 = pre(vec1), v2 = pre(vec2);
		if(i == 0) {
			res += (n1 / 2) * 2;
			continue;
		}
		else if(M % 2 == 0 && i == M / 2) {
			res += (n1 / 2) * 2;
			continue;
		}
		if(n1 > n2) {
			swap(n1, n2); swap(v1, v2);
		}
		// debug(v1, n1, v2, n2);
		int tmp;
		if((n1 + n2) % 2 == 0) {
			if(v2 <= n1) {
				tmp = (n1 + n2) / 2;
			}
			else {
				tmp = n1 + (n2 - v2) / 2;
			}
		}
		else {
			if(v2 <= n1 + 1) {
				tmp = (n1 + n2) / 2;
			}
			else {
				tmp = n1 + (n2 - v2) / 2;
			}
		}
		res += tmp;
	}
	cout << res / 2 << "\n";
}
int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


```