n,m,*X=list(map(int,open(0).read().split()))

E=[0]*(max(X)+1)

P=[0]*m

M=[0]*m

for x in X:E[x]+=1;M[x%m]+=1

for i,e in enumerate(E):P[i%m]+=e//2

ans=0

for i in range(m//2+1):

	if i==0 or i*2==m:

		ans+=M[i]//2

	else:

		l=min(M[i],M[(m-i)%m])

		ans+=l+min((M[i]-l)//2,P[i])+min((M[(m-i)%m]-l)//2,P[(m-i)%m])

print(ans)
n,m,*X=list(map(int,open(0).read().split()))

E=[0]*(max(X)+1)

P=[0]*m

M=[0]*m

for x in X:E[x]+=1;M[x%m]+=1

for i,e in enumerate(E):P[i%m]+=e//2

ans=0

min=lambda a,b: a if a<b else b

for i in range(m//2+1):

	if i==0 or i*2==m:

		ans+=M[i]//2

	else:

		l=min(M[i],M[(m-i)%m])

		ans+=l+min((M[i]-l)//2,P[i])+min((M[(m-i)%m]-l)//2,P[(m-i)%m])

print(ans)
n, m, *X = list(map(int, open(0).read().split()))
E = [0] * (max(X) + 1)
P = [0] * m
M = [0] * m
for x in X:
    E[x] += 1
    M[x % m] += 1
for i, e in enumerate(E):
    P[i % m] += e // 2
ans = 0
for i in range(m // 2 + 1):
    if i == 0 or i * 2 == m:
        ans += M[i] // 2
    else:
        l = min(M[i], M[(m - i) % m])
        ans += (
            l
            + min((M[i] - l) // 2, P[i])
            + min((M[(m - i) % m] - l) // 2, P[(m - i) % m])
        )
print(ans)

n, m, *X = list(map(int, open(0).read().split()))
E = [0] * (max(X) + 1)
P = [0] * m
M = [0] * m
for x in X:
    E[x] += 1
    M[x % m] += 1
for i, e in enumerate(E):
    P[i % m] += e // 2
ans = 0
min = lambda a, b: a if a < b else b
for i in range(m // 2 + 1):
    if i == 0 or i * 2 == m:
        ans += M[i] // 2
    else:
        l = min(M[i], M[(m - i) % m])
        ans += (
            l
            + min((M[i] - l) // 2, P[i])
            + min((M[(m - i) % m] - l) // 2, P[(m - i) % m])
        )
print(ans)

+min = lambda a, b: a if a < b else b