#include <bits/stdc++.h>
using namespace std;
int n, k, x;
int cnt[100];
int main() {
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    scanf("%d", &x);
    cnt[x % k]++;
  }
  x = 0;
  for (int i = 1; i <= k / 2; i++) {
    x += min(cnt[i], cnt[k - i]);
  }
  if (k % 2 == 0) x = x - cnt[k / 2] + cnt[k / 2] / 2;
  x += cnt[0] / 2;
  cout << x * 2;
  return 0;
}
