#include <bits/stdc++.h>
using namespace std;
int mod[101];
int main() {
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    long long d;
    cin >> d;
    d %= k;
    mod[d]++;
  }
  int count = mod[0] - (mod[0] % 2);
  for (int i = 1; i <= k / 2; i++) {
    if (i == k - i)
      count += mod[i] - (mod[i] % 2);
    else
      count += 2 * min(mod[i], mod[k - i]);
  }
  cout << count << "\n";
}
