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