import std.stdio;
import std.array;
import std.string;
import std.conv;
import std.algorithm;
import std.typecons;
import std.range;
import std.random;
import std.math;
import std.container;
import std.numeric;
import std.bigint;


void main() {
  auto input = readln.split.map!(to!int);
  auto N = input[0];
  auto M = input[1];
  auto X = readln.split.map!(to!int).array;
  auto cnt = new int[](10^^5+1);
  foreach (x; X) cnt[x] += 1;
  if 

  int ans = 0;
  foreach (i; 1..10^^5+1) {
    if (cnt[i] == 0) continue;
    foreach (j; iota(((i/M)+1)*M - (i%M), 10^^5+1, M)) {
      while (cnt[j] > 0 && cnt[i] > 0) {
        cnt[i]--;
        cnt[j]--;
        ans++;
      }
      if (cnt[i] == 0)
        break;
    }
  }
  writeln(ans+cnt.map!(x => x/2).sum);
}
