from collections import defaultdict, Counter

N, M = list(map(int, input().split()))

#X = list(map(int, input().split()))

C = Counter(list(map(int, input().split())))

D = defaultdict(int)

E = defaultdict(int)

for k, v in list(C.items()):

    D[k%M] += v

    E[k%M] += v//2



ans = D[0] // 2



for i in range(1, M):

    j = M - i

    if i < j:

        x = min(D[i], D[j])

        y = min((D[i] - x)//2, E[i]) + min((D[j] - x)//2, E[j])

        ans += x + y

    elif i == j:

        ans += D[i] //2

    else:

        break



print(ans)
from collections import defaultdict, Counter

N, M = list(map(int, input().split()))

C = Counter(list(map(int, input().split())))

#D = defaultdict(int)

#E = defaultdict(int)

D = [0]*M

E = [0]*M

for k, v in list(C.items()):

    D[k%M] += v

    E[k%M] += v//2



ans = D[0] // 2



for i in range(1, M):

    j = M - i

    if i < j:

        x = min(D[i], D[j])

        y = min((D[i] - x)//2, E[i]) + min((D[j] - x)//2, E[j])

        ans += x + y

    elif i == j:

        ans += D[i] //2

    else:

        break



print(ans)
from collections import defaultdict, Counter

N, M = list(map(int, input().split()))
# X = list(map(int, input().split()))
C = Counter(list(map(int, input().split())))
D = defaultdict(int)
E = defaultdict(int)
for k, v in list(C.items()):
    D[k % M] += v
    E[k % M] += v // 2
ans = D[0] // 2
for i in range(1, M):
    j = M - i
    if i < j:
        x = min(D[i], D[j])
        y = min((D[i] - x) // 2, E[i]) + min((D[j] - x) // 2, E[j])
        ans += x + y
    elif i == j:
        ans += D[i] // 2
    else:
        break
print(ans)

from collections import defaultdict, Counter

N, M = list(map(int, input().split()))
C = Counter(list(map(int, input().split())))
# D = defaultdict(int)
# E = defaultdict(int)
D = [0] * M
E = [0] * M
for k, v in list(C.items()):
    D[k % M] += v
    E[k % M] += v // 2
ans = D[0] // 2
for i in range(1, M):
    j = M - i
    if i < j:
        x = min(D[i], D[j])
        y = min((D[i] - x) // 2, E[i]) + min((D[j] - x) // 2, E[j])
        ans += x + y
    elif i == j:
        ans += D[i] // 2
    else:
        break
print(ans)

-# X = list(map(int, input().split())) -D = defaultdict(int) -E = defaultdict(int) +# D = defaultdict(int) +# E = defaultdict(int) +D = [0] * M +E = [0] * M