#include <bits/stdc++.h>
using namespace std;
int a[101];
int n, k, tmp;
int sum = 0;
int main() {
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> tmp;
    a[tmp % k]++;
  }
  sum += a[0] / 2;
  for (int i = 1; i < (k + 1) / 2; i++) {
    sum += min(a[i], a[k - i]);
  }
  if (k % 2 == 0) sum += a[k / 2] / 2;
  cout << sum * 2;
  return 0;
}
