#include <bits/stdc++.h>
using namespace std;
int num[200005];
int mod[100];
int main() {
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> num[i];
    mod[num[i] % k]++;
  }
  long long ans = 0;
  for (int i = 1; i <= k / 2; i++) {
    ans += min(mod[i], mod[k - i]);
    if (i != k - i)
      ans += min(mod[i], mod[k - i]);
    else {
      if (min(mod[i], mod[k - i]) % 2 == 1) ans--;
    }
  }
  ans += (mod[0] / 2) * 2;
  cout << ans << endl;
  return 0;
}
