#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-8;
const int INF = 0x3f3f3f3f;
const long long LLINF = 0x3f3f3f3f3f3f3f3f;
const int maxn = (int)5e5 + 17;
const int mod = (int)1e9 + 7;
int n, m;
int a[maxn];
int main() {
  while (~scanf("%d %d", &n, &m)) {
    memset(a, 0, sizeof(a));
    for (int i = 0; i < n; ++i) {
      int t;
      scanf("%d", &t);
      a[t % m]++;
    }
    int ans = a[0] / 2 * 2;
    for (int i = 1; i < m; ++i) {
      ans += min(a[i], a[m - i]);
      if (i == m - i && a[i] % 2) ans--;
    }
    printf("%d\n", ans);
  }
  return 0;
}
