#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, k;
  cin >> n >> k;
  unordered_map<int, int> m;
  for (long long int i = 0; i < n; i++) {
    long long int a;
    cin >> a;
    m[a % k]++;
  }
  vector<int> v;
  int ans = 0;
  for (auto it = m.begin(); it != m.end(); it++) v.push_back(it->first);
  sort(v.begin(), v.end());
  int c = 0;
  for (int i = 0; i < v.size(); i++) {
    c = 0;
    if ((2 * v[i]) % k == 0)
      ans += m[v[i]] / 2;
    else {
      for (int j = i + 1; j < v.size(); j++) {
        if ((v[i] + v[j]) % k == 0) c = m[v[j]];
      }
      ans += min(m[v[i]], c);
    }
  }
  cout << ans * 2 << endl;
  return 0;
}
