#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  map<int, int> m;
  int x;
  for (int i = 1; i <= n; i++) {
    cin >> x;
    x = x % k;
    m[x]++;
  }
  int sum = 0;
  int ll;
  sum = sum + (m[0] / 2);
  if (k % 2 == 0) {
    ll = k / 2 - 1;
    sum = sum + (m[k / 2] / 2);
  } else {
    ll = k / 2;
  }
  for (int i = 1; i <= ll; i++) {
    sum = sum + min(m[i], m[k - i]);
  }
  cout << sum * 2;
  return 0;
}
