#include <bits/stdc++.h>
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
using namespace std;
vector<long long int> v, v2, v3;
vector<long long int>::iterator it1, it2;
int ar[200];
int main() {
  long long int tcase = 1;
  while (tcase--) {
    long long int n, k, a, ans = 0;
    scanf("%lld %lld", &n, &k);
    for (int i = 0; i < n; i++) {
      scanf("%lld", &a);
      ar[a % k]++;
    }
    ans += ar[0] / 2;
    ar[0] = 0;
    for (int i = 1; i <= (k / 2) + 1; i++) {
      if (ar[i]) {
        if (ar[k - i] && i != (k - i)) {
          ans += min(ar[i], ar[k - i]);
          ar[i] = ar[k - i] = 0;
        } else if (ar[k - i] && (i == k - i)) {
          ans += ar[i] / 2;
          ar[i] = 0;
        }
      }
    }
    printf("%lld\n", 2 * ans);
  }
}
