#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  scanf(" %d %d", &n, &k);
  int a[110] = {0};
  for (int i = 0; i < n; i++) {
    int tmp;
    scanf(" %d", &tmp);
    a[tmp % k] += 1;
  }
  int ans = 0;
  ans += a[0] / 2;
  for (int i = 1; i < k; i++) {
    if (i == k - i) {
      ans += a[i] / 2;
      a[i] -= a[i] / 2;
    } else {
      int mn = min(a[i], a[k - i]);
      ans += mn;
      a[i] -= mn;
      a[k - i] -= mn;
    }
  }
  printf("%d\n", ans * 2);
  return 0;
}
