#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
int mp[maxn];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; ++i) {
    int t;
    cin >> t;
    mp[t % m]++;
  }
  int ans = 0;
  for (int i = 0; i <= m / 2; ++i) {
    if ((!i) || (!(m & 1) && i == m / 2)) {
      ans += (mp[i] >> 1) << 1;
    } else {
      ans += 2 * min(mp[i], mp[m - i]);
    }
  }
  cout << ans << endl;
}
