#include <bits/stdc++.h>
using namespace std;
int main() {
  int TC;
  int n, k, candyMods[105];
  memset(candyMods, 0, sizeof(candyMods));
  scanf("%d %d", &n, &k);
  for (int i = 0; i < n; i++) {
    int v;
    scanf("%d", &v);
    candyMods[v % k] += 1;
  }
  int ans = 0;
  for (int i = 1; i <= k / 2; i++) {
    if (i == k - i) {
      ans += (candyMods[i] / 2) * 2;
    } else {
      ans += min(candyMods[i], candyMods[k - i]) * 2;
    }
  }
  ans += (candyMods[0] / 2) * 2;
  printf("%d\n", ans);
  return 0;
}
