#include <bits/stdc++.h>
using namespace std;
int main() {
  int t = 1;
  while (t--) {
    int n, k;
    cin >> n >> k;
    int a[n];
    map<int, int> m;
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      m[a[i] % k]++;
    }
    int ans = 0;
    for (auto i : m) {
      if (i.first == 0) {
        ans += i.second / 2;
        continue;
        cout << ans << endl;
      }
      if (k % 2 == 0 && i.first == k / 2) {
        ans += i.second / 2;
        continue;
        cout << ans << endl;
      }
      if (i.first > (k) / 2) break;
      if (m.find(k - i.first) != m.end()) {
        auto itr = m.find(k - i.first);
        ans += (min(i.second, itr->second));
      }
    }
    cout << 2 * ans << endl;
  }
  return 0;
}
