#include <bits/stdc++.h>
using namespace std;
void file() {}
void fast() {
  std::ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
}
long long gcd(long long a, long long b) { return !b ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return (a / gcd(a, b)) * b; }
long long setbit(long long num, int idx, int val = 1) {
  return (val) ? (num | (1 << idx)) : (num & ~(1 << idx));
}
long long getbit(long long num, int idx) { return ((num >> idx) & 1) == 1; }
int contbit(int num) {
  int ret = 0;
  while (num) {
    if (num % 2) ret++;
    num /= 2;
  }
  return ret;
}
int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
int main() {
  file();
  fast();
  int n, k;
  cin >> n >> k;
  vector<int> a(101, 0);
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    x %= k;
    a[x]++;
  }
  if (a[0] % 2) a[0]--;
  int sum = a[0];
  for (int i = 1; i < k; i++) {
    int mn = min(a[i], a[k - i]);
    a[i] -= mn;
    a[k - i] -= mn;
    if (i == k - i)
      sum += mn - (mn % 2);
    else
      sum += 2 * mn;
  }
  cout << sum;
}
