#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using dbl = double;
using ldb = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using mii = map<int, int>;
using msi = map<string, int>;
using umii = unordered_map<int, int>;
using umsi = unordered_map<string, int>;
using iii = tuple<int, int, int>;
using lll = tuple<ll, ll, ll>;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) {
  if (!a || !b) return a + b;
  return a * (b / gcd(a, b));
}
const int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
int n, k;
int a[111];
int main() {
  scanf("%d %d", &n, &k);
  for (int i = 0; i < n; i++) {
    int x;
    scanf("%d", &x);
    a[x % k]++;
  }
  ll ans = 0;
  for (int i = 1; i < (k + 1) / 2; i++) {
    ans += min(a[i], a[k - i]);
  }
  if (k % 2 == 0) {
    ans += a[k / 2] / 2;
  }
  ans += a[0] / 2;
  printf("%lld ", ans * 2);
  return 0;
}
