#include <bits/stdc++.h>
const int maxn = 200007;
int box[maxn];
bool visit[maxn] = {false};
int count[107] = {false};
int min(int a, int b) {
  if (a > b) return b;
  return a;
}
int main() {
  int n, m;
  int sum = 0;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &box[i]);
    box[i] %= m;
  }
  for (int i = 1; i <= n; i++) {
    count[box[i]]++;
  }
  sum += (count[0] / 2);
  for (int i = 1; i <= m / 2; i++) {
    if (i * 2 == m) {
      sum += count[i] / 2;
    } else {
      if (count[i] && count[m - i]) {
        sum += min(count[i], count[m - i]);
      }
    }
  }
  printf("%d", sum * 2);
  return 0;
}
