def main():

  n,m=list(map(int,input().split()))

  x=list(map(int,input().split()))

  xmod=[y%m for y in x]

  from collections import Counter

  cx=Counter(x)

  cxmod=Counter(xmod)

  keys=list(cxmod.keys())

  ans1,ans2=0,0 # ams1:m倍になるペア、ans2:同数のペア。ans1からもとめる

  for k in keys:

    if k==0:

      ans1+=cxmod[k]//2

      cxmod[k]-=2*(cxmod[k]//2)

    else:

      if k==m-k:

        ans1+=cxmod[k]//2

        cxmod[k]-=2*(cxmod[k]//2)

      elif m-k in keys:

        tmp=min(cxmod[k],cxmod[m-k])

        ans1+=tmp

        cxmod[k]-=tmp

        cxmod[m-k]-=tmp

  for k in cx:

    v=cx[k]

    if v>=2 and cxmod[k%m]>=2:

      tmp=min(v//2,cxmod[k%m]//2)

      ans2+=tmp

      cxmod[k%m]-=tmp*2



  print((ans1+ans2))

if __name__=='__main__':

  main()



def main():

  n,m=list(map(int,input().split()))

  x=list(map(int,input().split()))

  xmod=[y%m for y in x]

  from collections import Counter

  cx=dict(Counter(x))

  cxmod=dict(Counter(xmod))

  keys=list(cxmod.keys())

  ans1,ans2=0,0 # ams1:m倍になるペア、ans2:同数のペア。ans1からもとめる

  for k in keys:

    if k==0:

      ans1+=cxmod[k]//2

      cxmod[k]-=2*(cxmod[k]//2)

    else:

      if k==m-k:

        ans1+=cxmod[k]//2

        cxmod[k]-=2*(cxmod[k]//2)

      elif m-k in keys:

        tmp=min(cxmod[k],cxmod[m-k])

        ans1+=tmp

        cxmod[k]-=tmp

        cxmod[m-k]-=tmp

  for k in cx:

    v=cx[k]

    if v>=2 and cxmod[k%m]>=2:

      tmp=min(v//2,cxmod[k%m]//2)

      ans2+=tmp

      cxmod[k%m]-=tmp*2



  print((ans1+ans2))

if __name__=='__main__':

  main()



def main():
    n, m = list(map(int, input().split()))
    x = list(map(int, input().split()))
    xmod = [y % m for y in x]
    from collections import Counter

    cx = Counter(x)
    cxmod = Counter(xmod)
    keys = list(cxmod.keys())
    ans1, ans2 = 0, 0  # ams1:m倍になるペア、ans2:同数のペア。ans1からもとめる
    for k in keys:
        if k == 0:
            ans1 += cxmod[k] // 2
            cxmod[k] -= 2 * (cxmod[k] // 2)
        else:
            if k == m - k:
                ans1 += cxmod[k] // 2
                cxmod[k] -= 2 * (cxmod[k] // 2)
            elif m - k in keys:
                tmp = min(cxmod[k], cxmod[m - k])
                ans1 += tmp
                cxmod[k] -= tmp
                cxmod[m - k] -= tmp
    for k in cx:
        v = cx[k]
        if v >= 2 and cxmod[k % m] >= 2:
            tmp = min(v // 2, cxmod[k % m] // 2)
            ans2 += tmp
            cxmod[k % m] -= tmp * 2
    print((ans1 + ans2))


if __name__ == "__main__":
    main()

def main():
    n, m = list(map(int, input().split()))
    x = list(map(int, input().split()))
    xmod = [y % m for y in x]
    from collections import Counter

    cx = dict(Counter(x))
    cxmod = dict(Counter(xmod))
    keys = list(cxmod.keys())
    ans1, ans2 = 0, 0  # ams1:m倍になるペア、ans2:同数のペア。ans1からもとめる
    for k in keys:
        if k == 0:
            ans1 += cxmod[k] // 2
            cxmod[k] -= 2 * (cxmod[k] // 2)
        else:
            if k == m - k:
                ans1 += cxmod[k] // 2
                cxmod[k] -= 2 * (cxmod[k] // 2)
            elif m - k in keys:
                tmp = min(cxmod[k], cxmod[m - k])
                ans1 += tmp
                cxmod[k] -= tmp
                cxmod[m - k] -= tmp
    for k in cx:
        v = cx[k]
        if v >= 2 and cxmod[k % m] >= 2:
            tmp = min(v // 2, cxmod[k % m] // 2)
            ans2 += tmp
            cxmod[k % m] -= tmp * 2
    print((ans1 + ans2))


if __name__ == "__main__":
    main()

-    cx = Counter(x) -    cxmod = Counter(xmod) +    cx = dict(Counter(x)) +    cxmod = dict(Counter(xmod))