#include <bits/stdc++.h>
using namespace std;
long double pi = acos(-1);
int dx[] = {1, 0, -1, 0, 1, 1, -1, -1}, dy[] = {0, 1, 0, -1, 1, -1, 1, -1},
    inf = 1e9, MOD = 1e9 + 7;
int n, k, d, a[111], ans;
int main() {
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> d;
    a[(d % k)]++;
  }
  ans = a[0] / 2;
  int b = 0;
  for (int i = 1; i < k; i++) {
    if (i != (k - i)) {
      b = min(a[i], a[k - i]);
      a[i] -= b;
      a[k - i] -= b;
    } else {
      b = a[i] / 2;
      a[i] -= 2 * b;
    }
    ans += b;
  }
  cout << ans * 2;
  return 0;
}
