#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  int n, k;
  cin >> n >> k;
  int arr[n], arr1[n];
  for (int i = 0; i < n; i++) cin >> arr[i];
  int y = 0, sum1 = 0;
  for (int i = 0; i < n; i++) {
    if (arr[i] % k != 0) {
      arr1[y] = arr[i] % k;
      y++;
    } else
      sum1++;
  }
  sort(arr1, arr1 + y + 1);
  int j = y;
  int sum = 0;
  for (int i = 0; i < j;) {
    if (arr1[i] + arr1[j] == k) {
      sum++;
      i++;
      j--;
    } else if (arr1[i] + arr1[j] < k)
      i++;
    else
      j--;
  }
  sum = sum + sum1 / 2;
  cout << sum * 2 << "\n";
}
