#include <bits/stdc++.h>
using namespace std;
const long double pi = 3.141592653589793;
int main() {
  ios::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
    v[i] %= k;
  }
  sort(v.begin(), v.end());
  int x = 0;
  while (x < n && v[x] == 0) x++;
  int ans = x / 2 * 2;
  int i = x, j = n - 1;
  while (i < j) {
    if (v[i] + v[j] == k) {
      ans += 2;
      i++;
      j--;
    } else {
      if (v[i] + v[j] > k)
        j--;
      else
        i++;
    }
  }
  cout << ans;
  return 0;
}
