#include <bits/stdc++.h>
using namespace std;
int main() {
  long long x, n, k, i, j, l, cnt = 0;
  cin >> n >> k;
  map<long, long> mp;
  long *arr = new long[n];
  for (i = 0; i < n; i++) {
    cin >> arr[i];
    mp[arr[i] % k]++;
    arr[i] = arr[i] % k;
  }
  for (i = 0; i < n; i++) {
    if (mp[arr[i]] > 0 && mp[(k - (arr[i])) % k] > 0) {
      mp[arr[i] % k]--;
      mp[(k - arr[i]) % k]--;
      if (mp[arr[i]] >= 0 && mp[(k - (arr[i])) % k] >= 0) cnt++;
    }
  }
  cout << cnt * 2;
}
