import sys

input = sys.stdin.readline

sys.setrecursionlimit(1000000)

from collections import deque

def getN():

    return int(eval(input()))

def getList():

    return list(map(int, input().split()))

import math



n, m = getList()

nums = getList()

n_mods = [0 for i in range(m)]

pair_mods = [0 for i in range(m)]

num_mods = [{} for i in range(m)]



for num in nums:

    modres = num % m

    n_mods[modres] += 1

    if num in num_mods[modres]:

        num_mods[modres][num] += 1

    else:

        num_mods[modres][num] = 1



    if num_mods[modres][num] % 2 == 0:

        pair_mods[modres] += 1



# print(n_mods)

# print(pair_mods)

ans = 0

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

    left = i

    right = m - i

    ans += min(n_mods[left], n_mods[right])

    if n_mods[left] > n_mods[right]:

        ans += max(0, min(pair_mods[left], (n_mods[left] - n_mods[right]) // 2))

    else:

        ans += max(0, min(pair_mods[right], (n_mods[right] - n_mods[left]) // 2))

    # print(left, right, ans)



ans += n_mods[0] // 2

if m % 2 == 0:

    ans += n_mods[m//2] // 2



print(ans)
import sys

input = sys.stdin.buffer.readline

def getN():

    return int(eval(input()))

def getNM():

    return list(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 list(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

"""
import sys

input = sys.stdin.readline
sys.setrecursionlimit(1000000)
from collections import deque


def getN():
    return int(eval(input()))


def getList():
    return list(map(int, input().split()))


import math

n, m = getList()
nums = getList()
n_mods = [0 for i in range(m)]
pair_mods = [0 for i in range(m)]
num_mods = [{} for i in range(m)]
for num in nums:
    modres = num % m
    n_mods[modres] += 1
    if num in num_mods[modres]:
        num_mods[modres][num] += 1
    else:
        num_mods[modres][num] = 1
    if num_mods[modres][num] % 2 == 0:
        pair_mods[modres] += 1
# print(n_mods)
# print(pair_mods)
ans = 0
for i in range(1, (m + 1) // 2):
    left = i
    right = m - i
    ans += min(n_mods[left], n_mods[right])
    if n_mods[left] > n_mods[right]:
        ans += max(0, min(pair_mods[left], (n_mods[left] - n_mods[right]) // 2))
    else:
        ans += max(0, min(pair_mods[right], (n_mods[right] - n_mods[left]) // 2))
    # print(left, right, ans)
ans += n_mods[0] // 2
if m % 2 == 0:
    ans += n_mods[m // 2] // 2
print(ans)

import sys

input = sys.stdin.buffer.readline


def getN():
    return int(eval(input()))


def getNM():
    return list(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 list(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
"""

-input = sys.stdin.readline -sys.setrecursionlimit(1000000) -from collections import deque +input = sys.stdin.buffer.readline -def getList(): +def getNM(): +    return list(map(int, input().split())) + + +def getlist(): +import heapq +from collections import defaultdict, Counter, deque -n, m = getList() -nums = getList() -n_mods = [0 for i in range(m)] -pair_mods = [0 for i in range(m)] -num_mods = [{} for i in range(m)] -for num in nums: -    modres = num % m -    n_mods[modres] += 1 -    if num in num_mods[modres]: -        num_mods[modres][num] += 1 -    else: -        num_mods[modres][num] = 1 -    if num_mods[modres][num] % 2 == 0: -        pair_mods[modres] += 1 -# print(n_mods) -# print(pair_mods) -ans = 0 -for i in range(1, (m + 1) // 2): -    left = i -    right = m - i -    ans += min(n_mods[left], n_mods[right]) -    if n_mods[left] > n_mods[right]: -        ans += max(0, min(pair_mods[left], (n_mods[left] - n_mods[right]) // 2)) -    else: -        ans += max(0, min(pair_mods[right], (n_mods[right] - n_mods[left]) // 2)) -    # print(left, right, ans) -ans += n_mods[0] // 2 -if m % 2 == 0: -    ans += n_mods[m // 2] // 2 -print(ans) +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 list(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 +"""