#include <bits/stdc++.h>
using namespace std;
int a[200005], x[105];
int main() {
  int b, c, ans = 0;
  cin >> b >> c;
  for (int h = 0; h < b; h++) {
    cin >> a[h];
    a[h] = a[h] % c;
    x[a[h]]++;
  }
  ans += x[0] / 2;
  if (c > 1) {
    for (int i = 1, j = c - 1; i < j; i++, j--) ans += min(x[i], x[j]);
    if (c % 2 == 0) ans += (x[c / 2]) / 2;
  }
  cout << ans * 2;
  return 0;
}
