output_description: Print the maximum number of pairs that can be created.
  
  * * *
input_description: The input is given from Standard Input in the following format:
  
      
      
      N M
      X_1 X_2 ... X_N
attempt: import sys
  
  input = sys.stdin.buffer.readline
  
  
  def getN():
      return int(input())
  
  
  def getNM():
      return map(int, input().split())
  
  
  def getlist():
      return list(map(int, input().split()))
  
  
  import math
  import heapq
  from collections import defaultdict, Counter, deque
  
  MOD = 10**9 + 7
  INF = 10**15
  
  
  def main():
      n, m = getlist()
      nums = getlist()
  
      cnt = Counter(nums)
      mod = [0 for i in range(m)]
      same = [0 for i in range(m)]
  
      for k, v in cnt.items():
          mod[k % m] += v
          same[k % m] += v // 2
  
      ans = mod[0] // 2
      for i in range(1, int((m + 2) // 2)):
          if i == m / 2:
              ans += mod[i] // 2
          else:
              other = m - i
              ans += min(mod[i], mod[other])
              if mod[i] > mod[other]:
                  ans += min(same[i], (mod[i] - mod[other]) // 2)
              if mod[i] < mod[other]:
                  ans += min(same[other], -(mod[i] - mod[other]) // 2)
  
      print(ans)
  
      # print(same, mod)
  
  
  if __name__ == "__main__":
      main()
  
  """
  9999
  3
  
  2916
  """
  
problem_description: Statement
  
  Takahashi is playing with N cards.
  
  The i-th card has an integer X_i on it.
  
  Takahashi is trying to create as many pairs of cards as possible satisfying
  one of the following conditions:
  
    * The integers on the two cards are the same.
    * The sum of the integers on the two cards is a multiple of M.
  
  Find the maximum number of pairs that can be created.
  
  Note that a card cannot be used in more than one pair.
samples: [{"input": "7 5\n    3 1 4 1 5 9 2", "output": "3\n    \n\nThree pairs (3,2), (1,4) and (1,9) can be created.\n\nIt is possible to create pairs (3,2) and (1,1), but the number of pairs is not\nmaximized with this.\n\n* * *"}, {"input": "15 10\n    1 5 6 10 11 11 11 20 21 25 25 26 99 99 99", "output": "6"}]