#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n{}, m{}, k{}, a{}, b{}, c{}, f{1}, q = 0;
  cin >> n >> k;
  std::vector<int> v;
  for (int i = 0; i < n; ++i) {
    cin >> a;
    a %= k;
    if (a == 0) {
      ++c;
    } else {
      v.push_back(a);
    }
  }
  sort(v.begin(), v.end());
  a = c / 2;
  n -= c;
  if (v.size() == 0) {
    cout << 2 * a << endl;
    return 0;
  }
  if (v[0] == v.back()) {
    if (k % v[0] == 0 && k / v[0] == 2) {
      a += n / (k / v[0]);
    }
    cout << 2 * a << endl;
    return 0;
  }
  int i = 0, j = n - 1;
  while (f) {
    f = 0;
    while (i < j) {
      if (v[i] + v[j] == k) {
        v[i] = 0;
        v[j] = 0;
        ++a;
        f = 1;
        ++i;
        --j;
        break;
      }
      if (v[i] + v[j] < k) ++i;
      if (v[i] + v[j] > k) --j;
    }
  }
  cout << 2 * a << endl;
  return 0;
}
