// Original C++ solution (slower):
/*

貪欲

後ろから見る

DP

順位表をチェック

二分探索





*/

#pragma GCC optimize("Ofast")

#include<cstdio>

#include<cstdlib>

#include<algorithm>

#include<iostream>

#include<queue>

#include<vector>

#include <bitset>

#include <cmath>

#include <limits>

#include <iostream>

#include <map>

#include<tuple>

using namespace std;

#define INF 3e18+7

#define MAX 100000

#define MOD 1000000007

typedef long long ll;

typedef pair<ll,ll> P;

//typedef pair<pair<int,int>,int> p;

#define bit(n,k) ((n>>k)&1) /*nのk bit目*/

#define rad_to_deg(rad) (((rad)/2/M_PI)*360)

struct edge{ll to,cost,val;};

template<class T,class U>bool chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}

template<class T,class U>bool chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}

//__builtin_popcount(S);

//C.erase(unique(C.begin(),C.end()),C.end());



int S[110000],Z[110000];





int main(){

    ios::sync_with_stdio(false);

    cin.tie(nullptr);



    int N,M,X;

    cin>>N>>M;



    vector<int> V[110000];

    for(int i=0;i<N;i++){

        cin>>X;

        V[X%M].push_back(X);

    }

    for(int i=0;i<M;i++){

        sort(V[i].begin(),V[i].end());

        S[i]=(int)V[i].size();

        int count=1;

        for(int j=0;j<S[i]-1;j++){

            if(V[i][j]==V[i][j+1]) count++;

            else{

                Z[i]+=count-count%2;

                count=1;

            }

        }

        Z[i]+=count-count%2;

    }

    int count=0;

    for(int i=0;i<=M/2;i++){

        if(i==0 || i*2==M){

            count+=S[i]/2;

            continue;

        }



        count+=min(S[i],S[M-i]);

        if(S[i]>S[M-i]){

            S[i]-=S[M-i];

            count+=min(Z[i],S[i])/2;

        }else{

            S[M-i]-=S[i];

            count+=min(Z[M-i],S[M-i])/2;

        }

    }

    cout<<count<<endl;



}

// Optimized solution to the same problem (faster):
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>

using namespace std;



typedef long long ll;

typedef pair<int,int> pii;

typedef pair<int,ll> pil;

typedef pair<ll,int> pli;

typedef pair<ll,ll> pll;



template<class T,class U>constexpr bool chmin(T&a,const U b){if(a<=b)return false;a=b;return true;}

template<class T,class U>constexpr bool chmax(T&a,const U b){if(a>=b)return false;a=b;return true;}

#define bit(n,k) ( (n>>k)&1 )



//デバッグ

template<class T>

void Vout(vector<T> &V){

    cout<<"\nstart\n";

    const int sz=V.size();

    for(int i=0;i<sz;i++){

        cout<<i<<" "<<V[i]<<'\n';

    }

    cout<<"end\n"<<endl;

}



//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++





constexpr int MAX=1<<30;

constexpr ll INF=1LL<<62;

constexpr int MOD=1e9+7;

int dx[]={1,-1,0,0},dy[]={0,0,-1,1};



//__builtin_popcount(S);

//#define int ll

//vector<vector<int>> data(3, vector<int>(4));

//vector.resize(a,vector<int>(b,-1));

//vector<vector<vector<要素の型>>> 変数名(要素数1, vector<vector<要素の型>>(要素数2, vector<要素の型>(要素数3, 初期値)));









signed main(){

    ios::sync_with_stdio(false);

    cin.tie(nullptr); 



    int N,M;

    cin>>N>>M;

    vector<int> V(N);

    for(int i=0;i<N;i++) cin>>V[i];



    int same[110000]={},num[110000]={};



    sort(V.begin(),V.end());

    for(int i=0;i<N-1;i++){

        if(V[i]==V[i+1]){

            same[V[i]%M]++;

            i++;

        }

    }

    for(int i=0;i<N;i++){

        num[V[i]%M]++;

    }

    int ans=0;

    for(int i=0;i<=M/2;i++){

        if(i*2%M==0){

            ans+=num[i]/2;

        }else{

            int x=M-i;

            int n=min(num[i],num[x]);

            num[i]-=n; num[x]-=n;

            ans+=n;

            ans+=min(num[i]/2,same[i]);

            ans+=min(num[x]/2,same[x]);

        }

    }

    cout<<ans<<endl;

}

// Fastest known solution for this problem: