#include <bits/stdc++.h>
using namespace std;
const int mod = int(1e9 + 7), MAXN = int(2e5 + 1);
int a[MAXN];
int b[MAXN];
int main() {
  int n, k, sol = 0;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    b[a[i] % k]++;
  }
  sol += b[0] - b[0] % 2;
  for (int i = 1; i <= (k - k % 2) / 2; i++) {
    if (i != k - i)
      sol += min(b[i], b[k - i]) * 2;
    else
      sol += b[i] - b[i] % 2;
  }
  cout << sol;
  return 0;
}
