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