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