#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 50;
int n, k, d[N];
int m[105];
int main(void) {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &d[i]);
    m[d[i] % k]++;
  }
  int ans = m[0] / 2 * 2;
  if (k % 2 == 0) {
    ans += m[k / 2] / 2 * 2;
  }
  for (int i = 1; i <= (k - 1) / 2; i++) {
    ans += 2 * min(m[i], m[k - i]);
  }
  printf("%d\n", ans);
  return 0;
}
