#include <bits/stdc++.h>
using namespace std;
const long long N = 100005;
const long long INF = 1000000000000000007;
const long long mod = 1000000007;
long long a[105];
void solve() {
  long long n, k, x;
  cin >> n >> k;
  memset(a, 0, sizeof(a));
  for (int i = 0; i < n; i++) {
    cin >> x;
    x %= k;
    a[x]++;
  }
  long long ans = 0;
  ans += floor(a[0] / 2) * 2;
  int nn = k - 1;
  for (int i = 1; i <= nn / 2; i++) {
    ans += min(a[i], a[nn - i + 1]) * 2;
  }
  if (nn % 2) {
    ans += floor(a[k / 2] / 2) * 2;
  }
  cout << ans << endl;
}
int main() {
  solve();
  return 0;
}
