#include <bits/stdc++.h>
using namespace std;
long long mod = 1000000007;
int main() {
  int n, k;
  cin >> n >> k;
  map<int, int> temp;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    temp[x % k]++;
  }
  int cnt = 0;
  for (auto it = temp.begin(); it != temp.end(); it++) {
    if (it->first == 0)
      cnt += 2 * (it->second / 2), it->second = 0;
    else {
      if (it->first == (k - (it->first)))
        cnt += 2 * (it->second / 2), it->second = 0;
      else {
        cnt += 2 * min(it->second, temp[k - (it->first)]);
        it->second = 0, temp[k - (it->first)] = 0;
      }
    }
  }
  cout << cnt << endl;
}
