#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  int p, b[100] = {0};
  for (int i = 0; i < n; i++) {
    cin >> p;
    b[p % k]++;
  }
  int count = 0;
  for (int j = 0; j <= k / 2; j++) {
    int x = b[j], y = b[k - j % k];
    if ((k - j % k) % k == j) {
      count += x / 2;
    } else {
      count += min(x, y);
    }
  }
  cout << 2 * count << endl;
  return 0;
}
