
import java.util.Scanner

import scala.collection.mutable

/**
 * Created by sonetsuyoshi on 2015/12/16.
 */
object Main extends App {
  val sc = new Scanner(System.in)
  val N = sc.nextInt
  val M = sc.nextInt

  val valCountMap = mutable.Map[Int, Int]().withDefaultValue(0)
  val modValMap = Array.fill(M)(mutable.Set[Int]())
  val modCountMap = Array.fill(M)(0)

  for(i <- 0 until N) {
    val n = sc.nextInt
    val m = n % M
    valCountMap.+=((n, valCountMap(n) + 1))
    modValMap(m).+=(n)
    modCountMap(m) += 1
  }

  var count = modCountMap(0) / 2
  for(i <- 1 to ((M - 1) / 2)) {
    val j = M - i
    val (sId, lId) = if(modCountMap(i) < modCountMap(j)) {
      (i, j)
    } else {
      (j, i)
    }

    val countDif = modCountMap(lId) - modCountMap(sId)
    val maxPairNum = countDif / 2

    val pairNum = modValMap(lId).foldLeft(0){case(s, x) => s + valCountMap(x) / 2}

    count += modCountMap(sId) + math.min(maxPairNum, pairNum)
  }

  if(M % 2 == 0) count += modCountMap(M / 2) / 2

  println(count)
}