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

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

from collections import Counter

mo=[[]for _ in range(m)]

for i in a:mo[i%m].append(i)

ans=len(mo[0])//2

if m%2==0:ans+=len(mo[m//2])//2

for i in range(1,0--m//2):

  if len(mo[i])>len(mo[m-i]):d=Counter(mo[i])

  elif len(mo[i])==len(mo[m-i]):

    ans+=len(mo[i])

    continue

  else:d=Counter(mo[m-i])

  anss=0

  for j in d:anss+=d[j]//2

  ans+=min(len(mo[i]),len(mo[m-i]))+min(abs(len(mo[i])-len(mo[m-i]))//2,anss)

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

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

a=[[]for _ in range(m)]

for i in x:a[i%m].append(i)

b=[]

from collections import Counter

for i in range(m):

  d=Counter(a[i])

  ans=0

  for j in d:ans+=2*(d[j]//2)

  b.append([len(a[i]),ans])

ans=0

if m%2==0:ans+=len(a[m//2])//2

ans+=len(a[0])//2

for i in range(1,0--m//2):

  sc,sp=b[i]

  tc,tp=b[m-i]

  v=min(sc,tc)

  ans+=v

  ans+=min(sp,sc-v)//2

  ans+=min(tp,tc-v)//2

print(ans)
n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
from collections import Counter

mo = [[] for _ in range(m)]
for i in a:
    mo[i % m].append(i)
ans = len(mo[0]) // 2
if m % 2 == 0:
    ans += len(mo[m // 2]) // 2
for i in range(1, 0 - -m // 2):
    if len(mo[i]) > len(mo[m - i]):
        d = Counter(mo[i])
    elif len(mo[i]) == len(mo[m - i]):
        ans += len(mo[i])
        continue
    else:
        d = Counter(mo[m - i])
    anss = 0
    for j in d:
        anss += d[j] // 2
    ans += min(len(mo[i]), len(mo[m - i])) + min(
        abs(len(mo[i]) - len(mo[m - i])) // 2, anss
    )
print(ans)

n, m = list(map(int, input().split()))
x = list(map(int, input().split()))
a = [[] for _ in range(m)]
for i in x:
    a[i % m].append(i)
b = []
from collections import Counter

for i in range(m):
    d = Counter(a[i])
    ans = 0
    for j in d:
        ans += 2 * (d[j] // 2)
    b.append([len(a[i]), ans])
ans = 0
if m % 2 == 0:
    ans += len(a[m // 2]) // 2
ans += len(a[0]) // 2
for i in range(1, 0 - -m // 2):
    sc, sp = b[i]
    tc, tp = b[m - i]
    v = min(sc, tc)
    ans += v
    ans += min(sp, sc - v) // 2
    ans += min(tp, tc - v) // 2
print(ans)

-a = list(map(int, input().split())) +x = list(map(int, input().split())) +a = [[] for _ in range(m)] +for i in x: +    a[i % m].append(i) +b = [] -mo = [[] for _ in range(m)] -for i in a: -    mo[i % m].append(i) -ans = len(mo[0]) // 2 +for i in range(m): +    d = Counter(a[i]) +    ans = 0 +    for j in d: +        ans += 2 * (d[j] // 2) +    b.append([len(a[i]), ans]) +ans = 0 -    ans += len(mo[m // 2]) // 2 +    ans += len(a[m // 2]) // 2 +ans += len(a[0]) // 2 -    if len(mo[i]) > len(mo[m - i]): -        d = Counter(mo[i]) -    elif len(mo[i]) == len(mo[m - i]): -        ans += len(mo[i]) -        continue -    else: -        d = Counter(mo[m - i]) -    anss = 0 -    for j in d: -        anss += d[j] // 2 -    ans += min(len(mo[i]), len(mo[m - i])) + min( -        abs(len(mo[i]) - len(mo[m - i])) // 2, anss -    ) +    sc, sp = b[i] +    tc, tp = b[m - i] +    v = min(sc, tc) +    ans += v +    ans += min(sp, sc - v) // 2 +    ans += min(tp, tc - v) // 2