#include <iostream>
#include <vector>
using namespace std;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n,k,sum=0;
cin>>n>>k;
vector<int> v(n+5);
int freq1[100005]={0},freq2[100005]={0};
for(int i=0;i<n;i++){
cin>>v[i];
if(v[i]<=100000){
freq1[v[i]]++;
}
if(v[i]>100000){
freq2[v[i]-100000]++;
}
}
for(int i=0;i<n;i++){
for(int j=i+1;j<n;j++){
if((v[i]+v[j])%k==0||(k%(v[i]+v[j])==0)){
if(v[i]>100000&&v[j]>100000){
if(v[i]==v[j]){
if(freq2[v[i]-100000]>=2){
sum+=2;
freq2[v[i]-100000]--;
freq2[v[j]-100000]--;
// cout<<v[i]<<" "<<v[j]<<" ";
break;
}
}
else if(freq2[v[i]-100000]>0&&freq2[v[j]-100000]>0){
sum+=2;
freq2[v[i]-100000]--;
freq2[v[j]-100000]--;
// cout<<v[i]<<" "<<v[j]<<" ";
break;
}
}
if(v[i]<=100000&&v[j]<=100000){
if(v[i]==v[j]){
if(freq1[v[i]]>=2){
sum+=2;
freq1[v[i]]--;
freq1[v[j]]--;
// cout<<v[i]<<" "<<v[j]<<" ";
break;
}
}
else if(freq1[v[i]]>0&&freq1[v[j]]>0){
sum+=2;
freq1[v[i]]--;
freq1[v[j]]--;
// cout<<v[i]<<" "<<v[j]<<" ";
break;
}
}
else if(v[i]>100000&&v[j]<=100000){
if(freq2[v[i]-100000]>0&&freq1[v[j]]>0){
sum+=2;
freq2[v[i]-100000]--;
freq1[v[j]]--;
// cout<<v[i]<<" "<<v[j]<<" ";
break;
}
}
else if(v[i]<=100000&&v[j]>100000){
if(freq1[v[i]]>0&&freq2[v[j]-100000]>0){
sum+=2;
freq1[v[i]]--;
freq2[v[j]-100000]--;
// cout<<v[i]<<" "<<v[j]<<" ";
break;
}
}
}
}
}
cout<<sum;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dmVjdG9yPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwppbnQgbWFpbigpewogICAgaW9zX2Jhc2U6OnN5bmNfd2l0aF9zdGRpbygwKTsKICAgIGNpbi50aWUoMCk7CiAgICBjb3V0LnRpZSgwKTsKICAgIGludCBuLGssc3VtPTA7CiAgICBjaW4+Pm4+Pms7CiAgICB2ZWN0b3I8aW50PiB2KG4rNSk7CiAgICBpbnQgZnJlcTFbMTAwMDA1XT17MH0sZnJlcTJbMTAwMDA1XT17MH07CiAgICBmb3IoaW50IGk9MDtpPG47aSsrKXsKICAgICAgICBjaW4+PnZbaV07CiAgICAgICAgaWYodltpXTw9MTAwMDAwKXsKICAgICAgICAgICAgZnJlcTFbdltpXV0rKzsKICAgICAgICB9CiAgICAgICAgaWYodltpXT4xMDAwMDApewogICAgICAgICAgICBmcmVxMlt2W2ldLTEwMDAwMF0rKzsKICAgICAgICB9CiAgICB9CiAgICBmb3IoaW50IGk9MDtpPG47aSsrKXsKICAgICAgICBmb3IoaW50IGo9aSsxO2o8bjtqKyspewogICAgICAgICAgICBpZigodltpXSt2W2pdKSVrPT0wfHwoayUodltpXSt2W2pdKT09MCkpewogICAgICAgICAgICAgICAgIGlmKHZbaV0+MTAwMDAwJiZ2W2pdPjEwMDAwMCl7CiAgICAgICAgICAgICAgICAgaWYodltpXT09dltqXSl7CiAgICAgICAgICAgICAgICAgaWYoZnJlcTJbdltpXS0xMDAwMDBdPj0yKXsKICAgICAgICAgICAgICAgICAgICAgICAgc3VtKz0yOwogICAgICAgICAgICAgICAgICAgICAgICBmcmVxMlt2W2ldLTEwMDAwMF0tLTsKICAgICAgICAgICAgICAgICAgICAgICAgZnJlcTJbdltqXS0xMDAwMDBdLS07CiAgICAgICAgICAgICAgICAgICAgICAvLyAgY291dDw8dltpXTw8IiAiPDx2W2pdPDwiICI7CiAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOyAgIAogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICBlbHNlIGlmKGZyZXEyW3ZbaV0tMTAwMDAwXT4wJiZmcmVxMlt2W2pdLTEwMDAwMF0+MCl7CiAgICAgICAgICAgICAgICAgICAgICAgIHN1bSs9MjsKICAgICAgICAgICAgICAgICAgICAgICAgZnJlcTJbdltpXS0xMDAwMDBdLS07CiAgICAgICAgICAgICAgICAgICAgICAgIGZyZXEyW3Zbal0tMTAwMDAwXS0tOwogICAgICAgICAgICAgICAgICAgICAgICAvLyBjb3V0PDx2W2ldPDwiICI8PHZbal08PCIgIjsKICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICBpZih2W2ldPD0xMDAwMDAmJnZbal08PTEwMDAwMCl7CiAgICAgICAgICAgICAgICAgaWYodltpXT09dltqXSl7CiAgICAgICAgICAgICAgICAgICAgaWYoZnJlcTFbdltpXV0+PTIpewogICAgICAgICAgICAgICAgICAgICAgICBzdW0rPTI7CiAgICAgICAgICAgICAgICAgICAgICAgIGZyZXExW3ZbaV1dLS07CiAgICAgICAgICAgICAgICAgICAgICAgIGZyZXExW3Zbal1dLS07CiAgICAgICAgICAgICAgICAgICAgICAvLyAgY291dDw8dltpXTw8IiAiPDx2W2pdPDwiICI7CiAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICBlbHNlIGlmKGZyZXExW3ZbaV1dPjAmJmZyZXExW3Zbal1dPjApewogICAgICAgICAgICAgICAgICAgICAgICBzdW0rPTI7CiAgICAgICAgICAgICAgICAgICAgICAgIGZyZXExW3ZbaV1dLS07CiAgICAgICAgICAgICAgICAgICAgICAgIGZyZXExW3Zbal1dLS07CiAgICAgICAgICAgICAgICAgICAgICAgIC8vIGNvdXQ8PHZbaV08PCIgIjw8dltqXTw8IiAiOwogICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgICBlbHNlIGlmKHZbaV0+MTAwMDAwJiZ2W2pdPD0xMDAwMDApewogICAgICAgICAgICAgICAgaWYoZnJlcTJbdltpXS0xMDAwMDBdPjAmJmZyZXExW3Zbal1dPjApewogICAgICAgICAgICAgICAgICAgICAgICBzdW0rPTI7CiAgICAgICAgICAgICAgICAgICAgICAgIGZyZXEyW3ZbaV0tMTAwMDAwXS0tOwogICAgICAgICAgICAgICAgICAgICAgICBmcmVxMVt2W2pdXS0tOwogICAgICAgICAgICAgICAgICAgICAgLy8gICBjb3V0PDx2W2ldPDwiICI8PHZbal08PCIgIjsKICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZWxzZSBpZih2W2ldPD0xMDAwMDAmJnZbal0+MTAwMDAwKXsKICAgICAgICAgICAgICAgIGlmKGZyZXExW3ZbaV1dPjAmJmZyZXEyW3Zbal0tMTAwMDAwXT4wKXsKICAgICAgICAgICAgICAgICAgICAgICAgc3VtKz0yOwogICAgICAgICAgICAgICAgICAgICAgICBmcmVxMVt2W2ldXS0tOwogICAgICAgICAgICAgICAgICAgICAgICBmcmVxMlt2W2pdLTEwMDAwMF0tLTsKICAgICAgICAgICAgICAgICAgICAgICAvLyBjb3V0PDx2W2ldPDwiICI8PHZbal08PCIgIjsKICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICB9CiAgICB9CiAgICBjb3V0PDxzdW07Cn0=