#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 100;
int vis[110];
int main() {
  int n, k;
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    int x;
    scanf("%d", &x);
    x = x % k;
    vis[x]++;
  }
  int ans = vis[0] / 2;
  int exa = 0;
  for (int i = 1; i < k; i++) {
    exa += min(vis[i], vis[k - i]);
  }
  ans += exa / 2;
  printf("%d\n", 2 * ans);
  return 0;
}
