#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1);
const long long mod = 1e9 + 7;
long long cnt[101];
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n, k;
  cin >> n >> k;
  for (long long i = 0; i < n; i++) {
    long long x;
    cin >> x;
    cnt[x % k]++;
  }
  if (k == 1) {
    return cout << (n / 2) * 2, 0;
  }
  long long tot1 = (cnt[0] / 2) * 2, tot = 0;
  if (k & 1) {
    for (long long kk = 1; kk <= k / 2; kk++) {
      tot += min(cnt[kk], cnt[k - kk]);
    }
  } else {
    for (long long kk = 1; kk < k / 2; kk++) {
      tot += min(cnt[kk], cnt[k - kk]);
    }
    tot += (cnt[k / 2] / 2);
  }
  cout << tot1 + 2 * tot;
  return 0;
}
