#include <bits/stdc++.h>
using namespace std;
int n, m;
const int N = 3e5 + 10;
int cnt[110];
int main() {
  cin >> n >> m;
  for (int i = 0, t = 0; i < n; ++i) {
    scanf("%d", &t);
    t %= m;
    cnt[t]++;
  }
  int res = 0;
  for (int i = 0; i < m; ++i) {
    if (i == (m - i) % m)
      res += cnt[i] / 2 * 2, cnt[i] %= 2;
    else {
      int t = min(cnt[i], cnt[(m - i) % m]);
      res += t * 2;
      cnt[i] -= t;
      cnt[(m - i) % m] -= t;
    }
  }
  cout << res << endl;
  return 0;
}
