#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, k, ans = 0;
  int a[105];
  cin >> n >> m;
  memset(a, 0, sizeof(a));
  for (int i = 0; i < n; i++) {
    cin >> k;
    k %= m;
    a[k]++;
  }
  ans = a[0] / 2;
  for (int i = 1, j = m - 1; i <= j; i++, j--) {
    if (i == j) {
      ans += a[i] / 2;
    } else {
      ans += min(a[i], a[j]);
    }
  }
  cout << ans * 2 << endl;
  return 0;
}
