#include <bits/stdc++.h>
using namespace std;
const long long Mod = 7 + 1e9;
const long long INF32 = 5 + 2e9;
const long long INF64 = 1 + 1e18;
const long long MAX = 5 + 3e5;
long long N, M, a[MAX], b[MAX];
string s;
int main() {
  cin >> N >> M;
  while (N--) {
    int x;
    cin >> x;
    a[x % M]++;
  }
  long long ans = a[0] / 2;
  a[0] = 0;
  for (int i = 1; i < M; i++) {
    if (i == M - i) {
      ans += a[i] / 2;
      continue;
    }
    int x = min(a[i], a[M - i]);
    a[i] -= x;
    a[M - i] -= x;
    ans += x;
  }
  cout << 2 * ans << endl;
  return 0;
}
