#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, x;
  cin >> n >> m;
  map<int, int> mp;
  for (int i = 0; i < n; i++) {
    cin >> x;
    x %= m;
    mp[x]++;
  }
  int res = mp[0];
  if (res % 2) res--;
  for (int i = 1; i < m; i++) {
    if (i != m - i) {
      res += min(mp[i], mp[m - i]) * 2;
      mp[i] = 0;
      ;
      mp[m - i] = 0;
    }
    if (i == m - i) {
      x = mp[i];
      if (x % 2) x--;
      res += x;
    }
  }
  cout << res << endl;
}
