fun main(args: Array<String>) {
  val (n, m) = readLine()!!.split(" ").map { it.toInt() }
  val x = readLine()!!.split(" ").map { it.toInt() }.sorted()
  var mpc = Array(m) { 0 }
  var mc = Array(m) { 0 }
  var p = 0
  for (i in 0 until n) {
    p++
    mc[x[i] % m]++
    if (i < n - 1 && x[i] == x[i + 1]) continue
    mpc[x[i] % m] += p / 2
    p = 0
  }
  var ans = mc[0] / 2
  if (m % 2 == 0) ans += mc[m / 2] / 2
  for (i in 1..(m - 1) / 2) {
    ans += if (mc[i] < mc[m - i]) {
      mc[i] + arrayOf((mc[m - i] - mc[i]) / 2, mpc[m - i]).min()!!
    } else {
      mc[m - i] + arrayOf((mc[i] - mc[m - i]) / 2, mpc[i]).min()!!
    }
  }
  println(ans)
}
