#include <bits/stdc++.h>
using namespace std;
int n, k;
int a[200001];
int frq[101];
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; i++) {
    scanf("%d", a + i);
    a[i] %= k;
    frq[a[i]]++;
  }
  long long ans = 0;
  for (int i = 0; i < k; i++) {
    if (i == 0 || i == k - i) {
      ans += (frq[i] / 2) * 2;
      frq[i] -= (frq[i] / 2) * 2;
    } else if (frq[i] > 0 && frq[k - i] > 0) {
      while (frq[i] && frq[k - i]) {
        ans += 2;
        frq[i]--;
        frq[k - i]--;
      }
    }
  }
  cout << ans << "\n";
  return 0;
}
