#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
int a, ans;
int c[120];
int main() {
  int n, k;
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> a;
    c[a % k]++;
  }
  for (int i = 1; i <= (k + 1) >> 1; i++) {
    int t = min(c[i], c[k - i]);
    if (i == k - i) {
      t = t - t % 2;
      c[i] -= t;
      ans += t;
    } else {
      ans += t * 2;
      c[i] -= t;
      c[k - i] -= t;
    }
  }
  ans += c[0] - c[0] % 2;
  cout << ans;
  return 0;
}
