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