#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<vector>
#define mp make_pair
#define fr first
#define sc second
using namespace std;

const int N=100005;

int n,ans,m,l,r,len,cnt,s,now,lft;
int a[N],b[N];
vector<int> lev[N];

int main(){
	int i,j;
	scanf("%d%d",&n,&m);
	for (i=1;i<=n;i++) scanf("%d",&a[i]);
	sort(a+1,a+1+n);
	for (i=1;i<=n;i++) lev[a[i]%m].push_back(a[i]);
	if (m%2==0) ans+=lev[m/2].size()/2;
	ans+=lev[0].size()/2;
	for (i=1;i<=m/2;i++){
		if (m%2==0&&i==m/2) break;
		if (lev[i].size()<lev[m-i].size()) swap(lev[i],lev[m-i]);
		ans+=lev[m-i].size();
		len=lev[i].size()-1; cnt=0;
		for (l=0;l<=len;l=r+1){
			for (r=l;r<len&&lev[i][l]==lev[i][r+1];r++);
			b[++cnt]=r-l+1;
		}
		sort(b+1,b+1+cnt); lft=len+1-lev[m-i].size(); 
		for (j=cnt;j;j--){
			if (lft<=1) break;
			now=min(lft,b[j]);
			lft-=now/2*2; ans+=now/2;
		}
	}
	printf("%d\n",ans);
	return 0;
}
### Prompt

Your task is to create 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<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<vector>
#define mp make_pair
#define fr first
#define sc second
using namespace std;

const int N=100005;

int n,ans,m,l,r,len,cnt,s,now,lft;
int a[N],b[N];
vector<int> lev[N];

int main(){
	int i,j;
	scanf("%d%d",&n,&m);
	for (i=1;i<=n;i++) scanf("%d",&a[i]);
	sort(a+1,a+1+n);
	for (i=1;i<=n;i++) lev[a[i]%m].push_back(a[i]);
	if (m%2==0) ans+=lev[m/2].size()/2;
	ans+=lev[0].size()/2;
	for (i=1;i<=m/2;i++){
		if (m%2==0&&i==m/2) break;
		if (lev[i].size()<lev[m-i].size()) swap(lev[i],lev[m-i]);
		ans+=lev[m-i].size();
		len=lev[i].size()-1; cnt=0;
		for (l=0;l<=len;l=r+1){
			for (r=l;r<len&&lev[i][l]==lev[i][r+1];r++);
			b[++cnt]=r-l+1;
		}
		sort(b+1,b+1+cnt); lft=len+1-lev[m-i].size(); 
		for (j=cnt;j;j--){
			if (lft<=1) break;
			now=min(lft,b[j]);
			lft-=now/2*2; ans+=now/2;
		}
	}
	printf("%d\n",ans);
	return 0;
}
```