#include <bits/stdc++.h>
using namespace std;
template <class T, class T1>
int chkmin(T &x, const T1 &y) {
  return x > y ? x = y, 1 : 0;
}
template <class T, class T1>
int chkmax(T &x, const T1 &y) {
  return x < y ? x = y, 1 : 0;
}
const int MAXN = (1 << 20);
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long T = 1;
  for (long long t = 0; t < T; t++) {
    long long n, k, ans = 0;
    cin >> n >> k;
    vector<long long> arr(n);
    map<long long, long long> rem;
    for (long long i = 0; i < n; i++) {
      cin >> arr[i];
      long long r = arr[i] % k;
      if (r == 0) {
        if (rem[r]) {
          ans++;
          rem[r]--;
        } else
          rem[r]++;
      } else {
        if (rem[k - r]) {
          ans++;
          rem[k - r]--;
        } else
          rem[r]++;
      }
    }
    cout << ans * 2 << '\n';
  }
  return 0;
}
