International Women's Day is coming soon! Polycarp is preparing for the holiday.

There are $n$ candy boxes in the shop for sale. The $i$-th box contains $d_i$ candies.

Polycarp wants to prepare the maximum number of gifts for $k$ girls. Each gift will consist of exactly two boxes. The girls should be able to share each gift equally, so the total amount of candies in a gift (in a pair of boxes) should be divisible by $k$. In other words, two boxes $i$ and $j$ ($i \ne j$) can be combined as a gift if $d_i + d_j$ is divisible by $k$.

How many boxes will Polycarp be able to give? Of course, each box can be a part of no more than one gift. Polycarp cannot use boxes "partially" or redistribute candies between them. 


-----Input-----

The first line of the input contains two integers $n$ and $k$ ($1 \le n \le 2 \cdot 10^5, 1 \le k \le 100$) — the number the boxes and the number the girls.

The second line of the input contains $n$ integers $d_1, d_2, \dots, d_n$ ($1 \le d_i \le 10^9$), where $d_i$ is the number of candies in the $i$-th box.


-----Output-----

Print one integer — the maximum number of the boxes Polycarp can give as gifts.


-----Examples-----
Input
7 2
1 2 2 3 2 4 10

Output
6

Input
8 2
1 2 2 3 2 4 6 10

Output
8

Input
7 3
1 2 2 3 2 4 5

Output
4



-----Note-----

In the first example Polycarp can give the following pairs of boxes (pairs are presented by indices of corresponding boxes):   $(2, 3)$;  $(5, 6)$;  $(1, 4)$. 

So the answer is $6$.

In the second example Polycarp can give the following pairs of boxes (pairs are presented by indices of corresponding boxes):   $(6, 8)$;  $(2, 3)$;  $(1, 4)$;  $(5, 7)$. 

So the answer is $8$.

In the third example Polycarp can give the following pairs of boxes (pairs are presented by indices of corresponding boxes):   $(1, 2)$;  $(6, 7)$. 

So the answer is $4$.

Source: codeforces | Difficulty: EASY
Tags: Number theory

Mathematics


Solutions:
(n, k) = list(map(int, input().split()))
d = list(map(int, input().split()))
ans = 0
l = []
for i in range(n):
	if d[i] % k == 0:
		ans = ans + 1
	else:
		l.append(d[i] % k)
ans = ans // 2
l.sort()
i = 0
j = len(l) - 1
while i < j:
	if k - l[i] == l[j]:
		i = i + 1
		j = j - 1
		ans = ans + 1
	elif k - l[i] < l[j]:
		j = j - 1
	elif k - l[i] > l[j]:
		i = i + 1
print(ans * 2)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
ost = [0] * (k + 1)
otv = 0
for elem in a:
	ost[elem % k] += 1
otv += ost[0] // 2
c = 1
if k % 2 == 0:
	c = 0
	otv += ost[k // 2] // 2
for i in range(1, k // 2 + c):
	otv += min(ost[i], ost[k - i])
print(otv * 2)


(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
d = [0 for i in range(k)]
for i in arr:
	d[i % k] += 1
ans = 0
for i in range(k // 2 + 1):
	if i == 0 or i == k - i:
		ans += d[i] // 2 * 2
	else:
		ans += min(d[i], d[k - i]) * 2
print(ans)


from sys import stdin
(n, k) = map(int, stdin.readline().strip().split())
s = list(map(int, stdin.readline().strip().split()))
d = dict()
for i in range(k):
	d[i] = 0
for i in s:
	x = i % k
	d[x] += 1
ans = d[0] // 2 * 2
for i in range(1, k):
	if i > k - i:
		continue
	if i != k - i:
		y = min(d[i], d[k - i])
	else:
		y = d[i] // 2
	ans += y * 2
print(ans)


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
r = [0] * k
c = 0
for i in l:
	r[i % k] += 1
c += r[0] - r[0] % 2
for i in range(1, len(r) // 2 + 1):
	if i == len(r) - i:
		c += r[i] // 2 * 2
	else:
		c += min(r[i], r[len(r) - i]) * 2
print(c)


(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
ans = 0
mod = [0] * k
for i in range(n):
	m = arr[i] % k
	if m == 0 and mod[0] != 0:
		ans += 1
		mod[0] -= 1
	elif m != 0 and mod[k - m] != 0:
		mod[k - m] -= 1
		ans += 1
	else:
		mod[m] += 1
print(ans * 2)


(_, k) = map(int, input().split())
nums = list(map(int, input().split()))
div = [0 for _ in range(k)]
for num in nums:
	div[num % k] += 1
answer = 0
answer += div[0] // 2
if not k % 2:
	answer += div[k // 2] // 2
i = 1
j = k - 1
while i < j:
	answer += min(div[i], div[j])
	i += 1
	j -= 1
print(answer * 2)


from math import ceil
(n, m) = map(int, input().split())
a = [int(i) % m for i in input().split()]
b = [0 for i in range(100)]
for i in a:
	b[i] += 1
ans = b[0] // 2
if m % 2 == 0:
	ans += b[m // 2] // 2
for i in range(1, ceil(m / 2)):
	ans += min(b[i], b[m - i])
print(ans * 2)


(n, k) = map(int, input().split())
a = [int(s) for s in input().split()]
b = [0 for i in range(k)]
for i in a:
	b[i % k] += 1
count = b[0] // 2
for i in range(1, (k + 1) // 2):
	count += min(b[i], b[k - i])
if k % 2 == 0:
	count += b[k // 2] // 2
print(count * 2)


(n, k) = map(int, input().split(' '))
arr = list(map(int, input().split(' ')))
for i in range(n):
	arr[i] = arr[i] % k
dic = {}
for elem in arr:
	if elem in dic:
		dic[elem] += 1
	else:
		dic[elem] = 1
res = 0
for (key, value) in dic.items():
	if key == 0:
		res += value // 2 * 2
	elif k - key in dic:
		if k - key == key and value > 1:
			res += value // 2 * 2
			dic[k - key] -= value // 2 * 2
		elif dic[key] > 0 and dic[k - key] > 0 and (k - key != key):
			val = min(dic[k - key], dic[key])
			res += val * 2
			dic[k - key] -= val
			dic[key] -= val
print(res)


(n, k) = [int(x) for x in input().split()]
a = list(map(int, input().split()))
d = dict()
d[0] = 0
for i in range(0, 101):
	d[i] = 0
for i in range(n):
	d[a[i] % k] += 1
ans = 0
for i in range(0, k):
	if d[i] == 0:
		continue
	if i == 0 or k - i == i:
		ans += d[i] // 2 * 2
		if d[i] % 2 == 0:
			d[i] = 0
		else:
			d[i] = 1
		continue
	if d[k - i] and k - i != i:
		mina = min(d[k - i], d[i])
		d[i] -= mina
		d[k - i] -= mina
		ans += 2 * mina
		continue
print(ans)


(n, k) = map(int, input().split())
d2 = {i: 0 for i in range(k)}
for i in list(map(int, input().split())):
	d2[i % k] += 1
answer = 0
for i in range(1, max(d2) + 1):
	now = min(d2[i], d2[k - i])
	d2[i] -= now
	d2[k - i] -= now
	if i == k - i:
		now //= 2
	answer += now
answer += d2[0] // 2
print(answer * 2)


(n, k) = list(map(int, input().split()))
di = list(map(int, input().split()))
ai = [0] * k
for i in di:
	ai[i % k] += 1
ans = ai[0] // 2
ai[0] = 0
for i in range(1, k):
	num = i
	num2 = k - i
	if num != num2:
		ans += min(ai[num], ai[num2])
	else:
		ans += ai[num] // 2
	ai[num] = 0
	ai[num2] = 0
print(ans * 2)


(n, k) = map(int, input().split())
c = list(map(int, input().split()))
dem = [0] * k
for i in c:
	j = i % k
	dem[j] += 1
total = dem[0] // 2
for i in range(1, k // 2 + 1):
	total += min(dem[i], dem[k - i])
if k % 2 == 0:
	if dem[k // 2] % 2 == 0:
		total -= dem[k // 2] / 2
	else:
		total -= dem[k // 2] // 2 + 1
print(int(total * 2))


from collections import Counter
(n, k) = map(int, input().split())
li = list(map(int, input().split()))
for i in range(n):
	li[i] %= k
arr = []
for i in range(k):
	arr.append(li.count(i))
c = 2 * (arr[0] // 2)
for i in range(1, k // 2 + 1):
	if i == k - i:
		c = c + arr[i] // 2 * 2
	else:
		c += 2 * min(arr[i], arr[k - i])
print(c)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
ms = [0] * k
for i in a:
	ms[i % k] += 1
mid = k // 2
co = ms[0] // 2
if k % 2 == 0:
	co += ms[mid] // 2
else:
	mid += 1
for i in range(1, mid):
	co += min(ms[i], ms[k - i])
print(co * 2)


(n, k) = map(int, input().split())
mas = list(map(int, input().split()))
ans = 0
q = [0] * k
for i in range(n):
	q[mas[i] % k] += 1
ans += q[0] - q[0] % 2
for i in range(1, k // 2 + 1):
	if i == k - i:
		ans += q[i] - q[i] % 2
	else:
		ans += min(q[i], q[k - i]) * 2
print(ans)


from collections import deque as de
import math
from collections import Counter as cnt

class My_stack:

	def __init__(self):
		self.data = []

	def my_push(self, x):
		return self.data.append(x)

	def my_pop(self):
		return self.data.pop()

	def my_peak(self):
		return self.data[-1]

	def my_contains(self, x):
		return self.data.count(x)

	def my_show_all(self):
		return self.data

	def isEmpty(self):
		return len(self.data) == 0
arrStack = My_stack()

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def get_prime_factors(number):
	prime_factors = []
	while number % 2 == 0:
		prime_factors.append(2)
		number = number / 2
	for i in range(3, int(math.sqrt(number)) + 1, 2):
		while number % i == 0:
			prime_factors.append(int(i))
			number = number / i
	if number > 2:
		prime_factors.append(int(number))
	return prime_factors

def get_frequency(list):
	dic = {}
	for ele in list:
		if ele in dic:
			dic[ele] += 1
		else:
			dic[ele] = 1
	return dic
(n, k) = map(int, input().split())
d = list(map(int, input().split()))
dd = []
nz = 0
for i in range(n):
	if d[i] % k:
		dd.append(d[i] % k)
	else:
		nz += 1
nz = nz // 2
dic = get_frequency(dd)
ans = 0
ans += nz
for key in dic:
	if k - key == key:
		if key in dic:
			ans += dic[key] // 2
	elif k - key in dic and dic[k - key] > 0 and (dic[key] > 0):
		ans += min(dic[k - key], dic[key])
		dic[k - key] = 0
		dic[key] = 0
print(ans * 2)


(n, k) = map(int, input().split())
m = list(map(int, input().split()))
r = [0] * k
ans = 0
for i in m:
	r[i % k] = r[i % k] + 1
for i in range(k // 2 + 1):
	if i == 0 or i == k / 2:
		ans = ans + r[i] // 2
	else:
		ans = ans + min(r[i], r[k - i])
print(ans * 2)


import math
(n, k) = list(map(int, input().split()))
d = list(map(int, input().split()))
freqArr = [0] * k
for i in d:
	mod = i % k
	freqArr[mod] += 1
total = 0
total += math.floor(freqArr[0] / 2)
if k % 2 == 0:
	total += math.floor(freqArr[math.floor(k / 2)] / 2)
for i in range(1, math.floor((k + 1) / 2)):
	total += min(freqArr[i], freqArr[k - i])
print(total * 2)


(n, k) = map(int, input().split())
cnt = [0] * k
for i in map(int, input().split()):
	cnt[i % k] += 1
ans = 2 * (cnt[0] // 2)
for i in range(1, k):
	if 2 * i >= k:
		break
	else:
		ans += 2 * min(cnt[i], cnt[k - i])
if k % 2 == 0:
	ans += 2 * (cnt[k // 2] // 2)
print(ans)


num = input().split(' ')
(n, k) = (int(num[0]), int(num[1]))
d = [int(x) for x in input().split(' ')]
for i in range(n):
	d[i] = d[i] % k
ans = 0
for i in range((k + 2) // 2):
	r = k - i
	if i != r and i != 0:
		ans += 2 * min(d.count(i), d.count(r))
	else:
		ans += 2 * (d.count(i) // 2)
print(ans)


first_line = input().split(' ')
box_num = int(first_line[0])
girl_num = int(first_line[1])
candy_num = input().split(' ')
candy_num = [int(x) for x in candy_num]
divi_array = [0] * girl_num
max_num = 0
for i in range(box_num):
	divi_value = int(candy_num[i] % girl_num)
	divi_array[divi_value] += 1
for i in range(int(girl_num / 2) + 1):
	if i == 0:
		max_num += int(divi_array[i] / 2) * 2
	elif divi_array[i] > divi_array[girl_num - i]:
		max_num += divi_array[girl_num - i] * 2
	elif divi_array[i] == divi_array[girl_num - i]:
		if i == girl_num - i:
			max_num += int(divi_array[i] / 2) * 2
		else:
			max_num += int(divi_array[i]) * 2
	else:
		max_num += divi_array[i] * 2
print(max_num)


import os
import sys
from io import BytesIO, IOBase
import math
from queue import Queue
import collections
import itertools
import bisect
import heapq
import random

def main():
	pass
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def binary(n):
	return bin(n).replace('0b', '')

def decimal(s):
	return int(s, 2)

def pow2(n):
	p = 0
	while n > 1:
		n //= 2
		p += 1
	return p

def primeFactors(n):
	l = []
	while n % 2 == 0:
		l.append(2)
		n = n / 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			l.append(i)
			n = n / i
	if n > 2:
		l.append(int(n))
	return l

def isPrime(n):
	if n == 1:
		return False
	else:
		root = int(n ** 0.5)
		root += 1
		for i in range(2, root):
			if n % i == 0:
				return False
		return True

def maxPrimeFactors(n):
	maxPrime = -1
	while n % 2 == 0:
		maxPrime = 2
		n >>= 1
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			maxPrime = i
			n = n / i
	if n > 2:
		maxPrime = n
	return int(maxPrime)

def countcon(s, i):
	c = 0
	ch = s[i]
	for i in range(i, len(s)):
		if s[i] == ch:
			c += 1
		else:
			break
	return c

def lis(arr):
	n = len(arr)
	lis = [1] * n
	for i in range(1, n):
		for j in range(0, i):
			if arr[i] > arr[j] and lis[i] < lis[j] + 1:
				lis[i] = lis[j] + 1
	maximum = 0
	for i in range(n):
		maximum = max(maximum, lis[i])
	return maximum

def isSubSequence(str1, str2):
	m = len(str1)
	n = len(str2)
	j = 0
	i = 0
	while j < m and i < n:
		if str1[j] == str2[i]:
			j = j + 1
		i = i + 1
	return j == m

def maxfac(n):
	root = int(n ** 0.5)
	for i in range(2, root + 1):
		if n % i == 0:
			return n // i
	return n

def p2(n):
	c = 0
	while n % 2 == 0:
		n //= 2
		c += 1
	return c

def seive(n):
	primes = [True] * (n + 1)
	primes[1] = primes[0] = False
	i = 2
	while i * i <= n:
		if primes[i] == True:
			for j in range(i * i, n + 1, i):
				primes[j] = False
		i += 1
	pr = []
	for i in range(0, n + 1):
		if primes[i]:
			pr.append(i)
	return pr

def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p

def denofactinverse(n, m):
	fac = 1
	for i in range(1, n + 1):
		fac = fac * i % m
	return pow(fac, m - 2, m)

def numofact(n, m):
	fac = 1
	for i in range(1, n + 1):
		fac = fac * i % m
	return fac

def sod(n):
	s = 0
	while n > 0:
		s += n % 10
		n //= 10
	return s
(n, k) = map(int, input().split())
l = list(map(int, input().split()))
cnt = {}
for i in range(0, k):
	cnt[i] = 0
for i in l:
	cnt[i % k] += 1
ans = 0
for i in range(0, k):
	if i == 0 or (k % 2 == 0 and i == k // 2):
		ans += cnt[i] - cnt[i] % 2
	else:
		ans += min(cnt[i], cnt[k - i])
print(ans)


(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
f = [0] * k
for e in arr:
	f[e % k] += 1
res = 0
res += f[0] // 2
for i in range(1, k // 2 + 1 if k & 1 else k // 2):
	res += min(f[i], f[k - i])
if k & 1 == 0:
	res += f[k // 2] // 2
print(2 * res)


(n, k) = map(int, input().split())
d = list(map(int, input().split()))
counts = [0] * k
for i in range(n):
	counts[d[i] % k] += 1
if k % 2 != 0:
	s = 0
	for i in range(1, k // 2 + 1):
		s += min(counts[i], counts[k - i])
	s += counts[0] // 2
	print(2 * s)
else:
	s = 0
	for i in range(1, k // 2):
		s += min(counts[i], counts[k - i])
	s += counts[k // 2] // 2
	s += counts[0] // 2
	print(2 * s)


(n, k) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
d = [0 for i in range(100)]
for i in a:
	d[i % k] += 1
r = int(d[0] / 2) * 2
for i in range(1, int((k - 1) / 2) + 1):
	r += min(d[i], d[k - i]) * 2
if k % 2 == 0:
	r += int(d[int(k / 2)] / 2) * 2
print(r)


(n, k) = (int(x) for x in input().split())
b = [int(x) for x in input().split()]
a = [0] * k
ans = 0
for i in range(n):
	d = b[i]
	a[d % k] += 1
ans += a[0] // 2
if k % 2 == 0:
	for i in range(1, k // 2):
		ans += min(a[i], a[k - i])
	ans += a[k // 2] // 2
else:
	for i in range(1, k // 2 + 1):
		ans += min(a[i], a[k - i])
print(ans * 2)


(a, b) = map(int, input().split())
array = list(map(int, input().split()))
cnt = [0 for _ in range(b)]
for i in range(a):
	cnt[array[i] % b] += 1
s = 0
if b % 2 == 0:
	s += cnt[b // 2] // 2
s += cnt[0] // 2
for i in range(1, (b + 1) // 2):
	s += min(cnt[i], cnt[b - i])
print(s * 2)


(n, k) = map(int, input().split())
a = [int(j) for j in input().split()]
freq = [0 for j in range(k)]
for x in a:
	freq[x % k] += 1
ans = freq[0] // 2
freq = freq[1:]
l = len(freq)
if l % 2 == 0:
	for i in range(l // 2):
		ans += min(freq[i], freq[l - i - 1])
	print(ans * 2)
else:
	for i in range(l // 2 + 1):
		if i == l - i - 1:
			ans += freq[i] // 2
		else:
			ans += min(freq[i], freq[l - i - 1])
	print(ans * 2)


(n, k) = list(map(int, input().split()))
nums = list(map(int, input().split()))
for i in range(n):
	nums[i] %= k
from math import floor
tot = 0
from collections import Counter
c = Counter(nums)
tot += floor(c[0] / 2) * 2
for i in range(1, k):
	if i != k - i:
		tot += min(c[i], c[k - i])
	else:
		tot += floor(c[i] / 2) * 2
print(tot)


(n, k) = map(int, input().split())
d = list(map(int, input().split()))
a = [0] * k
for i in d:
	a[i % k] += 1
mid = k // 2
ans = 0
if k % 2 == 0:
	ans += a[mid] // 2
else:
	mid += 1
ans += a[0] // 2
for i in range(1, mid):
	ans += min(a[i], a[k - i])
print(ans * 2)


(_, k) = map(int, input().split())
(stat, n) = ({i: 0 for i in range(k)}, 0)
for i in map(int, input().split()):
	if stat[(k - i % k) % k] > 0:
		(n, stat[(k - i % k) % k]) = (n + 2, stat[(k - i % k) % k] - 1)
	else:
		stat[i % k] += 1
print(n)


(n, k) = map(int, input().split())
d = map(int, input().split())
lists = [0 for x in range(k)]
for x in d:
	lists[x % k] += 1
del d
boxes = 0
for x in range(1, k // 2 + k % 2):
	boxes += 2 * min(lists[x], lists[k - x])
if k % 2 == 0:
	boxes += lists[k // 2] - lists[k // 2] % 2
boxes += lists[0] - lists[0] % 2
print(boxes)


def find_pairs(lst, k):
	i = 0
	j = len(lst) - 1
	result = 0
	while i < j:
		(x, y) = (lst[i], lst[j])
		s = x + y
		if s == k:
			result += 1
			i += 1
			j -= 1
		elif s < k:
			i += 1
		else:
			j -= 1
	return (result + lst.count(0) // 2) * 2
(n, K) = [int(w) for w in input().split()]
c = [int(z) for z in input().split()]
d = list()
for elem in c:
	d.append(elem % K)
print(find_pairs(sorted(d), K))


num = [0 for i in range(104)]
(n, k) = input().split()
n = int(n)
k = int(k)
d = map(int, input().split())
for e in d:
	num[e % k] += 1
ans = 0
for i in range(1, k):
	if i == k - i:
		ans += min(num[i], num[k - i]) // 2 * 2
	else:
		ans += min(num[i], num[k - i])
print(ans + num[0] // 2 * 2)


from bisect import bisect

def h(x, k):
	return x % k
(n, k) = map(int, input().split())
l = list(map(int, input().split()))
k = [k] * len(l)
s = 0
g = list(map(h, l, k))
h = set(g) - {0, k[0] / 2}
h = sorted(list(h))
p = bisect(h, k[0] // 2)
for i in range(p):
	r = g.count(h[i])
	w = g.count(k[0] - h[i])
	s = s + min(r, w)
print((s + g.count(0) // 2 + g.count(k[0] / 2) // 2) * 2)


(n, k) = map(int, input().split())
a = [int(x) for x in input().split()]
x = 0
count = [x for i in range(110)]
for i in range(n):
	count[a[i] % k] += 1
ans = count[0] // 2
j = 0
if k % 2 == 0:
	ans += count[k // 2] // 2
	j = k // 2
else:
	j = k // 2 + 1
for i in range(1, j):
	ans += min(count[i], count[k - i])
print(2 * ans)


(n, k) = map(int, input().split())
liczby = list(map(int, input().split()))
lista = []
wynik = 0
zera = 0
for x in range(n):
	reszta = liczby[x] % k
	lista.append(reszta)
lista.sort()
slownik = {}
a = 1
if n == 2:
	if lista[0] == lista[1]:
		slownik[lista[0]] = 2
	else:
		slownik[lista[0]] = 1
		slownik[lista[1]] = 1
else:
	for x in range(n - 1):
		if lista[x] == lista[x + 1]:
			a += 1
			if x == n - 2:
				if lista[x] == 0:
					zera += a
				else:
					slownik[lista[x]] = a
		else:
			if lista[x] == 0:
				zera += a
			else:
				slownik[lista[x]] = a
			a = 1
x = 1
y = k - 1
while x <= y:
	if x + y == k:
		try:
			if x != y:
				wynik += min(slownik[x], slownik[y])
				y -= 1
				x += 1
			else:
				wynik += slownik[x] // 2
				x += 1
		except:
			x += 1
	elif x + y > k:
		y -= 1
	else:
		x += 1
wynik += zera // 2
print(2 * wynik)


def main():
	(_n, k) = map(int, input().split(' '))
	d = [int(x) for x in input().split(' ')]
	d_mod_k = [x % k for x in d]
	counts = {}
	for i in range(k):
		counts[i] = 0
	for item in d_mod_k:
		counts[item] += 1
	num_pairs = 0
	for i in range(0, k // 2 + 1):
		counter_i = (k + k - i) % k
		if i == counter_i:
			num_pairs += counts[i] // 2
		else:
			num_pairs += min(counts[i], counts[counter_i])
	print(num_pairs * 2)
main()


(n, k) = map(int, input().split())
boxes = list(map(int, input().split()))
c = k * [0]
for box in boxes:
	c[box % k] += 1
out = c[0] // 2
for i in range(1, (k + 1) // 2):
	out += min(c[i], c[k - i])
if k % 2 == 0:
	out += c[k // 2] // 2
print(out * 2)


from sys import stdin, stdout
for _ in range(1):
	(n, k) = list(map(int, stdin.readline().split()))
	a = list(map(int, stdin.readline().split()))
	rem = [0] * k
	ans = 0
	for i in range(n):
		rem[a[i] % k] += 1
	for i in range(k):
		if k % 2 == 0 and i == k // 2 or i == 0:
			ans += rem[i] - 1 if rem[i] & 1 else rem[i]
			continue
		ans += min(rem[i], rem[k - i])
	print(ans)


(n, k) = list(map(int, input().split()))
num = list(map(int, input().split()))
gay = []
for i in num:
	gay.append(i % k)
number = [0] * 101
for i in gay:
	number[i] += 1
i = 0
chuj = 1
wynik = 0
while i < k:
	if i == (k - i) % k:
		if number[i] > 1:
			number[i] -= 2
			wynik += 1
		else:
			number[i] = 0
			i += 1
	else:
		if number[i] > 0:
			if number[(k - i) % k] > 0:
				number[i] -= 1
				number[(k - i) % k] -= 1
				wynik += 1
			else:
				number[i] = 0
		if number[i] == 0:
			i += 1
print(2 * wynik)


(n, k) = tuple(map(int, input().split()))
A = list(map(int, input().split()))
d = {}
ans = 0
zero = 0
for i in A:
	if i % k == 0:
		zero += 1
		continue
	if i % k in d.keys():
		d[i % k] += 1
	else:
		d[i % k] = 1
for i in list(d.items()):
	if i[0] > k // 2:
		continue
	if i[0] == k // 2 and k % 2 == 0:
		ans += i[1] // 2
	else:
		if k - i[0] not in d.keys():
			d[k - i[0]] = 0
		ans += min(d[i[0]], d[k - i[0]])
print(zero // 2 * 2 + ans * 2)


def get_ans(k, arr):
	remainders = dict.fromkeys(range(k), 0)
	for i in arr:
		remainders[i % k] += 1
	ans = remainders[0] // 2
	for i in range(1, (k + 1) // 2):
		ans += min(remainders[i], remainders[k - i])
	if k % 2 == 0:
		ans += remainders[k // 2] // 2
	return 2 * ans
(N, K) = map(int, input().split())
ARR = list(map(int, input().split()))
print(get_ans(K, ARR))


def main():
	from collections import Counter
	(n, k) = (int(i) for i in input().split())
	A = [int(i) % k for i in input().split()]
	c = Counter(A)
	ans = 0
	for i in range(k):
		if i > k - i:
			break
		if i == 0 or i + i == k:
			ans += c[i] // 2
		else:
			ans += min(c[i], c[k - i])
	print(ans * 2)
main()


TN = 1

def solution():
	(n, k) = map(int, input().split())
	d = list(map(int, input().split()))
	anss = [0 for i in range(k)]
	for i in range(n):
		anss[d[i] % k] += 1
	ans = anss[0] // 2 * 2
	if k % 2:
		for i in range(1, k // 2 + 1):
			ans += 2 * min(anss[i], anss[-i])
		print(ans)
	else:
		for i in range(1, k // 2):
			ans += 2 * min(anss[i], anss[-i])
		ans += anss[k // 2] // 2 * 2
		print(ans)
while TN != 0:
	solution()
	TN -= 1


(n, k) = list(map(int, input().split()))
d = list(map(int, input().split()))
di = dict()
for i in range(n):
	if d[i] % k in di:
		di[d[i] % k] += 1
	else:
		di[d[i] % k] = 1
ans = 0
if 0 in di:
	ans = di[0] // 2
for i in range(1, k // 2 + 1):
	if i in di and k - i in di:
		if i == k - i:
			ans += di[i] // 2
		else:
			ans += min(di[i], di[k - i])
print(ans * 2)


def d(n, k, a_list):
	m = [0] * k
	for a in a_list:
		m[a % k] += 1
	summ = m[0] // 2
	for i in range(1, k // 2 + 1):
		if i != k - i:
			summ += min(m[i], m[k - i])
	if k % 2 == 0:
		summ += m[k // 2] // 2
	return summ * 2
I = lambda : map(int, input().split())
(n, k) = I()
a = list(I())
print(d(n, k, a))


nk = [int(x) for x in input().strip().split(' ')]
n = nk[0]
k = nk[1]
boxes = [int(x) for x in input().strip().split(' ')]
nbBoxes = 0
remainders = {}
for i in boxes:
	key = i % k
	if key in remainders.keys():
		remainders[key] += 1
	else:
		remainders[key] = 1
nbBoxes += remainders.get(0, 0) // 2
for i in remainders.keys():
	complement = k - i
	if complement is i:
		nbBoxes += remainders[i] // 2
		remainders[i] %= 2
	else:
		pairs = min(remainders.get(i), remainders.get(complement, 0))
		if pairs is not 0:
			nbBoxes += pairs
			remainders[i] -= pairs
			remainders[complement] -= pairs
print(nbBoxes * 2)


import sys
input = sys.stdin.readline
(n, k) = map(int, input().split())
arr = [int(i) for i in input().split()]
cnt = 0
res = [0 for i in range(k)]
for i in arr:
	res[i % k] += 1
cnt = res[0] // 2
for i in range(1, len(res) // 2 + 1):
	if i == len(res) - i:
		cnt += res[i] // 2
		break
	else:
		cnt += min([res[i], res[len(res) - i]])
print(cnt * 2)


(z, zz) = (input, lambda : list(map(int, z().split())))
zzz = lambda : [int(i) for i in stdin.readline().split()]
(szz, graph, mod, szzz) = (lambda : sorted(zz()), {}, 10 ** 9 + 7, lambda : sorted(zzz()))
from string import *
from re import *
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
from heapq import *
from itertools import *
from bisect import *
from collections import Counter as cc
from math import factorial as f
from bisect import bisect as bs
from bisect import bisect_left as bsl
from itertools import accumulate as ac

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)

def prime(x):
	p = ceil(x ** 0.5) + 1
	for i in range(2, p):
		if x % i == 0 and x != 2 or x == 0:
			return 0
	return 1

def dfs(u, visit, graph):
	visit[u] = True
	for i in graph[u]:
		if not visit[i]:
			dfs(i, visit, graph)
(n, k) = zzz()
lst = zzz()
cnt = [0] * k
for i in lst:
	cnt[i % k] += 1
ans = cnt[0] // 2
l = 1
r = k - 1
while l < r:
	ans += min(cnt[l], cnt[r])
	l += 1
	r -= 1
if k % 2 == 0:
	ans += cnt[k // 2] // 2
print(ans * 2)


import sys, math, string, bisect
input = sys.stdin.readline
from collections import deque
L = lambda : list(map(int, input().split()))
Ls = lambda : list(input().split())
M = lambda : map(int, input().split())
I = lambda : int(input())
(n, k) = M()
l = L()
p = [0] * k
for i in range(n):
	p[l[i] % k] += 1
i = 1
j = k - 1
x = 0
while i <= j:
	if i == j:
		x += p[i] // 2
	else:
		x += min(p[i], p[j])
	i += 1
	j -= 1
x += p[0] // 2
print(x * 2)


(n, k) = [int(t) for t in input().split(' ')]
d = [int(t) % k for t in input().split(' ')]
cnt = [0] * k
for di in d:
	cnt[di] += 1
total = cnt[0] // 2 * 2
if k % 2 == 0:
	total += cnt[k // 2] // 2 * 2
	cnt[k // 2] = 0
for ki in range(1, k // 2 + 1):
	total += min(cnt[ki], cnt[k - ki]) * 2
print(total)


(n, k) = map(int, input().split())
d = list(map(int, input().split()))
cnt = [0 for _ in range(k)]
for di in d:
	cnt[di % k] += 1
ans = 0
for i in range(1, k):
	ans += min(cnt[i], cnt[k - i])
ans //= 2
ans += cnt[0] // 2
print(2 * ans)


(n, k) = [int(x) for x in input().split()]
d = [int(x) for x in input().split()]
c = {}
for x in d:
	if x % k in c:
		c[x % k] += 1
	else:
		c[x % k] = 1
boxes = 0
for x in range(k):
	a = x % k
	b = (k - x) % k
	if a not in c or b not in c:
		continue
	if a == b:
		boxes += 2 * (c[a] // 2)
	else:
		boxes += min(c[a], c[b])
print(boxes)


(n, k) = list(map(int, input().split()))
d = list(map(int, input().split()))
a = [p % k for p in d]
s = a.count(0) // 2
if k % 2 == 0:
	s += a.count(k / 2) // 2
for i in range(1, (k + 1) // 2):
	s += min(a.count(i), a.count(k - i))
print(s * 2)


(n, k) = map(int, input().split())
candy = list(map(int, input().split()))
dicttotal = dict.fromkeys(range(k), 0)
answer = 0
for i in range(n):
	dicttotal[candy[i] % k] += 1
answer += dicttotal[0] // 2
if k % 2 == 0:
	answer += dicttotal[k / 2] // 2
for i in range(1, (k + 1) // 2):
	answer += min(dicttotal[i], dicttotal[k - i])
answer *= 2
print(answer)


(a, b) = map(int, input().split())
z = list(map(int, input().split()))
s = [0 for n in range(b)]
for n in z:
	s[n % b] += 1
k = s[0] // 2 * 2
for n in range(1, b // 2 + 1):
	if 2 * n == b:
		k += 2 * (s[n] // 2)
	else:
		p = min(s[n], s[b - n])
		k += 2 * p
print(k)


(n, k) = map(int, input().split())
col = map(int, input().split())
r = [0] * k
for v in col:
	r[v % k] += 1
res = r[0] // 2
x = 1
y = k - 1
while x <= y:
	if x < y:
		res += min(r[x], r[y])
	else:
		res += r[x] // 2
	x += 1
	y -= 1
print(2 * res)


(n, k) = map(int, input().split())
d = list(map(lambda x: int(x) % k, input().split()))
m = [True] * len(d)
c = {i: 0 for i in range(k)}
for i in d:
	c[i] += 1
s = c[0] // 2
if k % 2 == 0:
	s += c[k // 2] // 2
for i in range(1, (k + 1) // 2):
	s += min(c[i], c[k - i])
print(2 * s)


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
d = [0] * k
for i in range(n):
	d[l[i] % k] += 1
c = d[0] // 2
if k % 2 == 0:
	c = c + d[k // 2] // 2
for i in range(1, (k + 1) // 2):
	c = c + min(d[i], d[k - i])
print(c * 2)


l = list(map(int, input().split()))
n = l[0]
k = l[1]
l = []
b = []
for i in range(k):
	b.append(int(0))
l = list(map(int, input().split()))
for i in l:
	b[i % k] += 1
sum = b[0] - b[0] % 2
for i in range(1, (k + 1) // 2):
	sum += min(b[i], b[k - i]) * 2
if k % 2 == 0:
	sum += b[k // 2] - b[k // 2] % 2
print(sum)


(n, k) = map(int, input().split())
d = list(map(int, input().split()))
count = [0] * k
for x in d:
	count[x % k] += 1
result = count[0] // 2
for i in range(1, k):
	if i * 2 >= k:
		break
	result += min(count[i], count[k - i])
if k % 2 == 0:
	result += count[k // 2] // 2
print(result * 2)


from sys import stdin
(n, k) = map(int, stdin.readline().split())
arr = list(map(int, stdin.readline().split()))
d = {}
for i in range(n):
	if arr[i] % k in d:
		d[arr[i] % k] += 1
	else:
		d[arr[i] % k] = 1
if 0 in d:
	count = 2 * (d[0] // 2)
else:
	count = 0
s = 0
for ele in d:
	if ele == 0:
		pass
	elif k - ele in d:
		if k - ele != ele:
			s += 2 * min(d[ele], d[k - ele])
		elif d[ele] > 1:
			s += 4 * (d[ele] // 2)
		else:
			pass
	else:
		pass
print(count + s // 2)


from sys import stdin, stdout
(n, k) = [int(x) for x in stdin.readline().split()]
a = [int(x) for x in stdin.readline().split()]
c = 0
h = [0 for i in range(k)]
for i in range(n):
	h[a[i] % k] += 1
c += h[0] // 2
if k % 2 == 0:
	c += h[k // 2] // 2
	for i in range(1, k // 2):
		c += min(h[i], h[-i])
else:
	for i in range(1, k // 2 + 1):
		c += min(h[i], h[-i])
print(c * 2)


(n, k) = map(int, input().split())
D = list(map(int, input().split()))
z = {i: 0 for i in range(k)}
for i in range(n):
	z[D[i] % k] += 1
cnt = z[0] // 2
for q in range(1, k // 2 + k % 2):
	cnt += min(z[q], z[k - q])
if k % 2 == 0:
	cnt += z[k // 2] // 2
print(cnt * 2)


import sys
from collections import defaultdict as dd
from itertools import permutations as pp
from itertools import combinations as cc
from collections import Counter as ccd
from random import randint as rd
from bisect import bisect_left as bl
import heapq
mod = 10 ** 9 + 7

def ri(flag=0):
	if flag == 0:
		return [int(i) for i in sys.stdin.readline().split()]
	else:
		return int(sys.stdin.readline())
(n, k) = ri()
a = ri()
take = [0 for i in range(105)]
nee = [0 for i in range(105)]
for i in a:
	take[i % k] += 1
	nee[i % k] += 1
ans = 0
ans += take[0] // 2 * 2
for i in range(1, k):
	if i == k - i:
		ans += take[i] // 2 * 2
	elif k - i >= 0:
		ans += min(take[i], take[k - i])
print(ans)


(n, k) = map(int, input().split())
li = [int(k) for k in input().split()]
con = []
for j in range(k):
	con.append(0)
for i in range(n):
	con[li[i] % k] += 1
ans = int(con[0] // 2)
if k % 2 == 0:
	ans = ans + con[int(k // 2)] // 2
x = int(k // 2)
for a in range(1, int((k + 1) // 2)):
	ans = ans + min(con[a], con[k - a])
print(ans * 2)


(n, k) = map(int, input().split())
arr = [int(x) for x in input().split()]
l = []
for i in range(k):
	l.append(0)
for i in range(n):
	l[arr[i] - k * (arr[i] // k)] += 1
sum = 2 * (l[0] // 2)
for i in range(1, k // 2 + 1):
	if i == k - i:
		sum += 2 * (min(l[i], l[k - i]) // 2)
	else:
		sum += 2 * min(l[i], l[k - i])
print(sum)


import sys
from collections import Counter
sys.setrecursionlimit(10 ** 5 + 1)
inf = int(10 ** 20)
max_val = inf
min_val = -inf
RW = lambda : sys.stdin.readline().strip()
RI = lambda : int(RW())
RMI = lambda : [int(x) for x in sys.stdin.readline().strip().split()]
RWI = lambda : [x for x in sys.stdin.readline().strip().split()]
(nb_boxes, nb_girls) = RMI()
candies = Counter([x % nb_girls for x in RMI()])
ways = 0
for i in range(nb_girls):
	curr = (nb_girls - i) % nb_girls
	if curr == i:
		way = candies[i] // 2
		candies[i] -= way * 2
		ways += way * 2
	else:
		way = min(candies[i], candies[curr])
		candies[i] -= way
		candies[curr] -= way
		ways += way * 2
print(ways)


(n, k) = list(map(int, input().split()))
d = list(map(int, input().split()))
cook = dict()
for i in range(k):
	cook[i] = 0
for i in range(n):
	cook[d[i] % k] += 1
Ans = 2 * (cook[0] // 2)
cook[0] -= 2 * (cook[0] // 2)
for i in range(1, k):
	if i == k - i:
		Ans += 2 * (min(cook[i], cook[k - i]) // 2)
		cook[i] -= 2 * (min(cook[i], cook[k - i]) // 2)
	else:
		Ans += 2 * min(cook[i], cook[k - i])
		L = min(cook[i], cook[k - i])
		cook[i] -= L
		cook[k - i] -= L
print(Ans)


import math
(n, k) = map(int, input().split())
candies = list(map(int, input().split()))
mod = [0 for _ in range(k)]
for nu in candies:
	mod[nu % k] += 1
ans = math.floor(mod[0] / 2)
ans *= 2
for i in range(1, k):
	if i != k - i:
		ans += min(mod[i], mod[k - i])
	else:
		ans += mod[i] if mod[i] % 2 == 0 else mod[i] - 1
print(ans)


from collections import defaultdict

def solve():
	(N, K) = map(int, input().split())
	D = [int(k) for k in input().split()]
	d = defaultdict(int)
	ans = 0
	for x in D:
		if x % K == 0:
			ans += 1
			continue
		d[x % K] += 1
	Keys = set(d.keys())
	ans = ans // 2 * 2
	for x in Keys:
		if x == K - x:
			ans += d[x] // 2 * 2
			del d[x]
		elif K - x in d:
			ans += min(d[K - x], d[x]) * 2
			del d[x]
	print(ans)
solve()


def C(inp):
	return inp // 2
(n, k) = map(int, input().split())
ls = list(map(int, input().split()))
if k == 1:
	print(n // 2 * 2)
elif n == 1:
	print(0)
else:
	ls = [i % k for i in ls]
	count = {}
	for i in ls:
		try:
			count[i] += 1
		except:
			count[i] = 1
	Sum = 0
	for i in range(1, k // 2):
		try:
			Sum += min(count[i], count[k - i])
		except:
			Sum += 0
	if k % 2 == 0:
		try:
			Sum += C(count[k // 2])
		except:
			Sum += 0
	else:
		try:
			Sum += min(count[k // 2], count[k - k // 2])
		except:
			Sum += 0
	try:
		Sum += C(count[0])
	except:
		Sum += 0
	print(Sum * 2)


import math
x = input()
n = int(x.split()[0])
k = int(x.split()[1])
x = input()
boxes = []
for i in x.split():
	boxes.append(int(i))
mods = []
for i in range(k):
	mods.append(0)
for i in boxes:
	mods[i % k] += 1
ans = 0
for i in range(1, math.floor(k / 2) + 1):
	if i == k / 2:
		ans += math.floor(mods[i] / 2)
	else:
		ans += min(mods[i], mods[k - i])
ans += math.floor(mods[0] / 2)
print(ans * 2)


from collections import Counter
(n, k) = map(int, input().split())
s = list(map(int, input().split()))
s = Counter(list(map(lambda x: x % k, s)))
cnt = s[0] // 2
for i in range(1, k // 2 + 1):
	cnt += min(s[i], s[k - i])
print(cnt * 2 - (k % 2 == 0) * (s[k // 2] + s[k // 2] % 2))


def number_of_gifts(arr, N, K):
	frequency = [0] * K
	for i in range(0, N):
		frequency[arr[i] % K] += 1
	ans = 0
	ans += frequency[0] // 2
	if K % 2 == 0:
		ans += frequency[k // 2] // 2
	i = 1
	while i <= K // 2 and i != K - i:
		ans += min(frequency[i], frequency[K - i])
		i += 1
	return ans * 2
(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
print(number_of_gifts(arr, n, k))


def maxPairs(nums, k):
	m = {}
	result = 0
	for i in nums:
		if i in m and m[i] > 0:
			m[i] = m[i] - 1
			result += 1
		elif k - i in m:
			m[k - i] += 1
		else:
			m[k - i] = 1
	return result

def solve():
	(n, k) = map(int, input().split())
	d = list(map(lambda x: int(x) % k, input().split()))
	return (d.count(0) // 2 + maxPairs(d, k)) * 2
print(solve())


nk = list(map(int, input().split(' ')))
(n, k) = (nk[0], nk[1])
mods = [0 for i in range(k)]
ds = list(map(int, input().split(' ')))
for i in range(n):
	mods[ds[i] % k] += 1
total = mods[0] if mods[0] % 2 == 0 else mods[0] - 1
for i in range(1, int(k / 2) + 1):
	if i != k - i:
		total += 2 * min(mods[i], mods[k - i])
	else:
		total += mods[i] if mods[i] % 2 == 0 else mods[i] - 1
print(total)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
g = [0] * k
c = 0
for i in range(n):
	g[a[i] % k] += 1
for i in range(k):
	for j in range(i, k):
		if i != j and (i + j) % k == 0:
			c += min(g[i], g[j]) * 2
			g[i] -= min(g[i], g[j])
			g[j] -= min(g[i], g[j])
		elif i == j and (i + j) % k == 0:
			c += g[i] - g[i] % 2
			g[i] = g[i] % 2
print(c)


(n, k) = list(map(int, input().split()))
a = list(map(int, input().split()))
for i in range(n):
	a[i] = a[i] % k
b = [0] * k
for i in range(n):
	b[a[i]] += 1
c = 0
for i in range(1, (k + 2) // 2):
	if i == k - i:
		d = b[i] // 2
	else:
		d = min(b[i], b[k - i])
	c = c + d
print((c + b[0] // 2) * 2)


(n, k) = map(int, input().split())
l = map(int, input().split())
f = [0 for i in range(0, k)]
for i in l:
	f[i % k] = f[i % k] + 1
ans = f[0] // 2
for i in range(1, k // 2 + 1):
	if i == k - i:
		ans = ans + f[i] // 2
	else:
		ans = ans + min(f[i], f[k - i])
print(2 * ans)


a = list(map(int, input().split()))
n = a[0]
k = a[1]
D = list(map(int, input().split()))
D = [a % k for a in D]
H = [D.count(x) for x in range(k)]
q = H[0] // 2 * 2
for i in range(1, k // 2 + 1):
	if i == k - i:
		q += H[i] // 2 * 2
	else:
		q += min(H[i], H[k - i]) * 2
print(q)


(n, k) = map(int, input().split())
boxes = list(map(int, input().split()))
count = {}
for b in boxes:
	count[b % k] = count.get(b % k, 0) + 1
ans = count.get(0, 0) // 2
if k % 2 == 0:
	ans += count.get(k // 2, 0) // 2
for i in range(1, (k + 1) // 2):
	ans += min(count.get(i, 0), count.get(k - i, 0))
print(ans * 2)


num = [0 for i in range(104)]
(numBoxes, girls) = input().split()
numBoxes = int(numBoxes)
girls = int(girls)
caixas = map(int, input().split())
for e in caixas:
	num[e % girls] += 1
qtdCaixas = 0
for i in range(1, girls):
	if i == girls - i:
		qtdCaixas += min(num[i], num[girls - i]) // 2 * 2
	else:
		qtdCaixas += min(num[i], num[girls - i])
print(qtdCaixas + num[0] // 2 * 2)


(n, k) = map(int, input().split())
A = [0 for i in range(k)]
answer = 0
for i in input().split(' '):
	if A[-int(i) % k] > 0:
		answer += 2
		A[-int(i) % k] -= 1
	else:
		A[int(i) % k] += 1
print(answer)


from collections import Counter
(n, k) = map(int, input().split())
d = list(map(int, input().split()))
rems = []
for x in d:
	rems.append(x % k)
c = Counter(rems)
t = 0
for i in range(0, k // 2 + 1):
	if i == 0:
		t += c[i] - c[i] % 2
	elif i == k // 2 and k - i == k // 2:
		t += c[i] - c[i] % 2
	else:
		x = min(c[i], c[k - i])
		t += 2 * x
print(t)


import sys

def main():
	(n, k) = map(int, input().split())
	d = list(map(int, sys.stdin.readline().split()))
	cong = [0] * k
	for i in range(n):
		cong[d[i] % k] += 1
	s = cong[0] // 2 * 2
	if k % 2 == 0:
		s += cong[k // 2] // 2 * 2
		for i in range(1, k // 2):
			s += min(cong[i], cong[k - i]) * 2
	else:
		for i in range(1, k // 2 + 1):
			s += min(cong[i], cong[k - i]) * 2
	print(s)
main()


(n, k) = map(int, input().split(' '))
gifts = sorted(list(map(lambda cnd: int(cnd) % k, input().split())))
equal_classes = [0] * k
etalon = gifts[0]
for g in gifts:
	if g == etalon:
		equal_classes[g] += 1
	else:
		etalon = g
		equal_classes[g] += 1
ans = equal_classes[0] - equal_classes[0] % 2
if (k - 1) % 2 == 1:
	equal_classes[k // 2] = equal_classes[k // 2] - equal_classes[k // 2] % 2
for i in range(1, k):
	ans += min(equal_classes[i], equal_classes[k - i])
print(ans)


(n, k) = [int(x) for x in input().split()]
boxes = [int(x) for x in input().split()]
aux = [0] * k
for i in boxes:
	aux[i % k] += 1
resp = aux[0] // 2
if k % 2 == 0:
	resp += aux[k // 2] // 2
for i in range(1, (k + 1) // 2):
	j = k - i
	resp += min(aux[i], aux[j])
print(resp * 2)


iin = lambda : int(input())
lin = lambda : list(map(int, input().split()))
(n, k) = lin()
a = lin()
sa = [0 for i in range(k)]
for i in a:
	sa[i % k] += 1
sol = set()
ans = 0
for i in range(k):
	for j in range(k):
		if (i + j) % k == 0 and i not in sol and (j not in sol):
			if i == j:
				ans += sa[i] // 2
			else:
				ans += min(sa[i], sa[j])
			sol.add(i)
			sol.add(j)
print(ans * 2)


(z, zz) = (input, lambda : list(map(int, z().split())))
(n, k) = zz()
lst = zz()
cnt = [0] * k
for i in lst:
	cnt[i % k] += 1
ans = cnt[0] // 2
l = 1
r = k - 1
while l < r:
	ans += min(cnt[l], cnt[r])
	l += 1
	r -= 1
if k % 2 == 0:
	ans += cnt[k // 2] // 2
print(ans * 2)


(n, k) = list(map(int, input().split()))
counts = [0] * k
for i in map(int, input().split()):
	counts[i % k] += 1
c = counts[0] // 2
for i in range(1, k):
	if 2 * i >= k:
		break
	c += min(counts[i], counts[k - i])
if k % 2 == 0:
	c += counts[k // 2] // 2
print(2 * c)


(n, k) = list(map(int, input().split()))
l = list(map(int, input().split()))
s = 0
l2 = [0 for j in range(k)]
for i in l:
	l2[i % k] += 1
m = k // 2 + 1
for i in range(m):
	if i == 0:
		s += l2[i] // 2 * 2
	elif i == k - i:
		s += min(l2[i], l2[k - i]) // 2 * 2
	else:
		s += min(l2[i], l2[k - i]) * 2
print(s)


(n, k) = map(int, input().split())
d = input().split()
d = [int(i) % k for i in d]
dm = {}
ans = 0
for i in d:
	if i not in dm:
		dm.update({i: 1})
	else:
		dm[i] += 1
for (k1, v) in dm.items():
	for (k2, v2) in dm.items():
		if k2 != k1:
			if (k2 + k1) % k == 0:
				ans += min(dm[k1], dm[k2])
		elif (k1 + k2) % k == 0:
			ans += dm[k1] - dm[k1] % 2
print(ans)


(n, K) = map(int, input().split())
arr = map(int, input().split())
freq = [0 for _ in range(K)]
for x in arr:
	freq[x % K] += 1
ans = 2 * (freq[0] // 2)
for i in range(1, K):
	if i < K - i:
		ans += 2 * min(freq[i], freq[K - i])
	elif i == K - i:
		ans += 2 * (freq[i] // 2)
print(ans)


(n, k) = map(int, input().split())
d = [int(x) for x in input().split()]
cnt = {i: 0 for i in range(k)}
for i in d:
	cnt[i % k] += 1
amnt = cnt[0] // 2
for i in range(1, k // 2):
	amnt += min(cnt[i], cnt[(k - i) % k])
if k > 1:
	if not k % 2:
		amnt += cnt[k // 2] // 2
	else:
		amnt += min(cnt[k // 2], cnt[(k - k // 2) % k])
print(2 * amnt)


c = 0
(n, k) = map(int, input().split())
l = [*map(int, input().split())]
f = [0 for i in range(k)]
for i in l:
	f[i % k] += 1
c = f[0] // 2
i = 1
j = k - 1
while i <= j:
	if i != j:
		c += min(f[i], f[j])
	else:
		c += f[i] // 2
	i += 1
	j -= 1
print(c * 2)


(n, k) = list(map(int, input().split()))
a = list(map(int, input().split()))
candies = [0] * k
counter = 0
for i in a:
	i = i % k
	if candies[(k - i) % k] > 0:
		candies[(k - i) % k] -= 1
		counter += 2
	else:
		candies[i] += 1
print(counter)


(n, k) = map(int, input().split())
d = [i % k for i in map(int, input().split())]
from collections import Counter
c = Counter(d)
ans = 0
for i in [*c.keys()]:
	for j in [*c.keys()]:
		if i + j in [0, k]:
			if i == j:
				ans += c[i] // 2
				c[i] = 0
			else:
				ans += min(c[i], c[j])
				c[i] = c[j] = 0
print(ans * 2)


import sys
sys.setrecursionlimit(1000000)
(n, k) = map(int, input().split())
c = list(map(int, input().split()))
d = {i: 0 for i in range(k)}
for ci in c:
	d[ci % k] += 1
a = d[0] // 2
for i in range(1, (k + 1) // 2):
	a += min(d[i], d[k - i])
if k % 2 == 0:
	a += d[k // 2] // 2
print(a * 2)


from math import ceil
(n, k) = map(int, input().split())
ans = 0
mods = [[] for i in range(k)]
candies = map(int, input().split())
for c in candies:
	mods[c % k].append(1)
for i in range(1, ceil(k / 2)):
	ans += min(len(mods[i]), len(mods[k - i]))
if k % 2 == 0:
	ans += len(mods[k // 2]) // 2
ans += len(mods[0]) // 2
print(2 * ans)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
(n, k) = map(int, input().split())
candies = list(map(int, input().split()))
gifts = 0
dict1 = {}
for j in range(k):
	dict1[j] = 0
for j in range(n):
	rem = candies[j] % k
	dict1[rem] += 1
for j in range(k // 2 + 1):
	if j == 0:
		gifts += dict1[j] // 2
	elif j == k // 2 and k % 2 == 0:
		gifts += dict1[j] // 2
	else:
		gifts += min(dict1[j], dict1[(k - j) % k])
print(gifts * 2)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
c = [0] * (k + 1)
count = 0
null = 0
for i in range(n):
	if a[i] % k == 0:
		null += 1
	elif c[k - a[i] % k] == 0:
		c[a[i] % k] += 1
	else:
		count += 1
		c[k - a[i] % k] -= 1
print(count * 2 + null // 2 * 2)


(n, k) = list(map(int, input().split()))
l = list(map(int, input().split()))
arr = [0 for i in range(k)]
for i in l:
	arr[i % k] += 1
ans = 0
for i in range(1, k // 2 + 1):
	min_val = min(arr[i], arr[k - i])
	if i == k - i:
		min_val //= 2
	ans += min_val
print(ans * 2 + arr[0] // 2 * 2)


(n, k) = map(int, input().split())
w = [0 for _ in range(k)]
a = map(lambda x: int(x) % k, input().split())
for i in a:
	w[i % k] += 1
s = (w[0] >> 1) + sum((min(w[i], w[k - i]) if i != k - i else w[i] >> 1 for i in range(1, (k >> 1) + 1)))
print(s << 1)


(n, k) = map(int, input().split(' '))
a = list(map(int, input().split(' ')))
c = 0
m = 0
odd = []
even = []
l = []
for _ in range(k):
	l.append(0)
for i in a:
	l[i % k] += 1
c += l[0] // 2
for i in range(1, k // 2 + 1):
	if i != k - i:
		c += min(l[i], l[k - i])
	else:
		c += l[i] // 2
print(c * 2)


from sys import stdin, stdout
from collections import Counter
(n, k) = input().strip().split(' ')
(n, k) = (int(n), int(k))
boxes = list(map(int, stdin.readline().strip().split(' ')))

def mo(x):
	global k
	return x % k
boxes = Counter(list(map(mo, boxes)))
ans = 0
if 0 in boxes:
	ans += boxes[0] // 2
if k % 2 == 0:
	for i in range(1, k // 2):
		if i in boxes and k - i in boxes:
			ans += min(boxes[i], boxes[k - i])
	if k // 2 in boxes:
		ans += boxes[k // 2] // 2
else:
	for i in range(1, k // 2 + 1):
		if i in boxes and k - i in boxes:
			ans += min(boxes[i], boxes[k - i])
print(ans * 2)


(n, k) = map(int, input().split())
xs = list(map(int, input().split()))
s = {}
for (i, x) in enumerate(xs):
	xs[i] = xs[i] % k
	if xs[i] not in s:
		s[xs[i]] = 1
	else:
		s[xs[i]] += 1
ans = 0
for x in xs:
	if s[x] == 0:
		continue
	s[x] -= 1
	if k - x in s and s[k - x] > 0:
		ans += 1
		s[k - x] -= 1
	elif 0 in s and s[0] > 0 and (k == 0 or x == 0):
		ans += 1
		s[0] -= 1
print(ans * 2)


(n, k) = map(int, input().split())
d = input().split()
a = [0 for mod in range(k)]
count = 0
for i in range(n):
	if a[(k - int(d[i]) % k) % k] > 0:
		count += 1
		a[(k - int(d[i]) % k) % k] -= 1
	else:
		a[int(d[i]) % k] += 1
print(2 * count)


from collections import defaultdict
import math
(n, k) = map(int, input().split())
l = list(map(int, input().split()))
d = defaultdict(int)
for i in l:
	d[i % k] += 1
count = 0
count += d[0] // 2 * 2
for i in range(1, math.ceil(k // 2) + 1):
	if i != k - i:
		count += min(d[i], d[k - i]) * 2
	else:
		count += d[i] // 2 * 2
print(count)


(packages, girls) = map(int, input().split())
sweets = list(map(int, input().split()))
presents = 0
osts = {}
for sweet in sweets:
	osts.setdefault(sweet % girls, 0)
	osts[sweet % girls] += 1
if girls % 2 == 0:
	osts.setdefault(girls / 2, 0)
	presents += int(osts[girls / 2] / 2)
	osts[girls / 2] = 0
osts.setdefault(0, 0)
presents += int(osts[0] / 2)
osts[0] = 0
for ost in osts:
	presents += min(osts[ost], osts.get(girls - ost, 0))
	osts[ost] = 0
print(presents * 2)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
doces = [0] * k
c = 0
for i in a:
	i = i % k
	if doces[(k - i) % k] > 0:
		doces[(k - i) % k] -= 1
		c += 2
	else:
		doces[i] += 1
print(c)


(n, k) = map(int, input().split())
l1 = list(map(int, input().split()))
l2 = [0] * k
for item in l1:
	l2[item % k] += 1
t = 0
for i in range(0, k // 2 + 1):
	if i == 0:
		t += 2 * (l2[i] // 2)
	elif i != k - i:
		t += 2 * min(l2[i], l2[k - i])
	elif l2[i] > 1:
		t += 2 * (l2[i] // 2)
print(t)


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
for i in range(n):
	l[i] = l[i] % k
hash = {}
for i in range(n):
	try:
		hash[l[i]]
	except:
		hash[l[i]] = 1
	else:
		hash[l[i]] += 1
k1 = set(l)
count = 0
for i in range(n):
	if l[i] != 0:
		z = k - l[i]
		if z in k1:
			if z != l[i]:
				if hash[l[i]] > 0 and hash[z] > 0:
					hash[l[i]] -= 1
					hash[z] -= 1
					count += 1
			elif hash[l[i]] > 1 and hash[z] > 1:
				hash[l[i]] -= 1
				hash[z] -= 1
				count += 1
	else:
		z = 0
		if z in k1:
			if hash[l[i]] > 1 and hash[z] > 1:
				hash[l[i]] -= 1
				hash[z] -= 1
				count += 1
print(2 * count)


(n, k) = map(int, input().split(' '))
s = input()
l = list(map(int, s.split()))
x = [0] * k
for j in l:
	x[j % k] += 1
ans = x[0] // 2
for i in range(1, k):
	if i == k - i:
		ans += x[i] // 2
	elif i < k - i:
		ans += min(x[i], x[k - i])
print(ans * 2)


from collections import defaultdict
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
d = defaultdict(int)
for val in a:
	d[val % k] += 1
res = d[0] // 2
(l, r) = (1, k - 1)
while l <= r:
	d[l] -= 1
	d[r] -= 1
	if d[l] >= 0 and d[r] >= 0:
		res += 1
	else:
		l += 1
		r -= 1
print(2 * res)


(n, k) = map(int, input().split())
d = map(int, input().split())
rests = [0] * k
pairs = 0
for di in d:
	di = di % k
	if rests[(k - di) % k] == 0:
		rests[di] += 1
	else:
		rests[(k - di) % k] -= 1
		pairs += 2
print(pairs)


import sys

def rint():
	return map(int, sys.stdin.readline().split())
(n, k) = rint()
d = list(rint())
for i in range(n):
	d[i] = d[i] % k
nd = [0] * k
for i in range(n):
	nd[d[i] % k] += 1
ans = 0
ans0 = nd[0] // 2
ans = 0
for i in range(1, k):
	ans += min(nd[i], nd[k - i])
ans = ans // 2 + ans0
print(ans * 2)


R = lambda : map(int, input().split())
(n, k) = R()
c = [0] * k
for x in R():
	c[x % k] += 1
print(sum(map(min, zip(c[1:], c[::-1]))) + (c[0] & ~1) - (~k & c[k // 2] & 1))


(n, k) = map(int, input().split())
A = list(map(int, input().split()))
C = [0] * k
for a in A:
	C[a % k] += 1
ans = C[0] // 2
if k % 2 == 0:
	ans += C[k // 2] // 2
for i in range(1, (k + 1) // 2):
	ans += min(C[i], C[k - i])
print(ans * 2)


from math import ceil
(n, k) = map(int, input().split())
rem = [0 for i in range(k)]
l = list(map(int, input().split()))
for i in range(n):
	rem[l[i] % k] = rem[l[i] % k] + 1
ans = 0
if k % 2 == 0:
	r = int(k / 2) + 1
elif k % 2 == 1:
	r = ceil(k / 2)
for i in range(r):
	if i == 0 or i == k - i:
		ans = ans + int(rem[i] / 2)
	else:
		ans = ans + min(rem[i], rem[k - i])
print(2 * ans)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
b = []
for i in range(0, k):
	b.append(0)
for i in range(0, n):
	b[a[i] % k] += 1
ans = b[0] - b[0] % 2
for i in range(1, k // 2 + 1):
	if i != k - i:
		ans += min(b[i], b[k - i]) * 2
	else:
		ans += b[i] - b[i] % 2
print(ans)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
b = dict()
ans = 0
for x in a:
	h = b.get((k - x) % k, -1)
	if h > 0:
		b[(k - x) % k] = h - 1
		ans += 2
	else:
		h = b.get(x % k, 0)
		b[x % k] = h + 1
print(ans)


from collections import Counter
(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
dic = {}
for i in arr:
	try:
		dic[i % k] += 1
	except:
		dic[i % k] = 1
t = 0
f = 0
for i in dic:
	try:
		x = min(dic[k - i], dic[i])
		dic[k - i] -= x
		dic[i] -= x
		if i == k - i:
			t += x // 2
		else:
			t += x
	except:
		f = 1
	if i % k == 0:
		t += dic[i] // 2
print(2 * t)


(n, k) = map(int, input().split())
d = list(map(int, input().split()))
counter = [0] * k
for x in d:
	counter[x % k] += 1
res = 0
for i in range(k):
	if i < (k - i) % k:
		res += min(counter[i], counter[(k - i) % k]) * 2
	elif i == (k - i) % k:
		res += counter[i] // 2 * 2
print(res)


(n, k) = map(int, input().split())
c = list(map(int, input().split()))
b = [0] * k
ans = 0
for p in c:
	b[p % k] += 1
ans += b[0] // 2
if k % 2 == 0:
	ans += b[k // 2] // 2
	for i in range(1, k // 2):
		ans += min(b[i], b[-i])
else:
	for i in range(1, k // 2 + 1):
		ans += min(b[i], b[-i])
print(ans * 2)


from itertools import groupby
from collections import defaultdict, Counter
(n, k) = map(int, input().split())
l = list(map(int, input().split()))
d = defaultdict(int)
for i in l:
	d[i % k] += 1
ans = d[0] // 2
mid = k // 2
if k % 2 == 0:
	ans += d[mid] // 2
else:
	mid += 1
for i in range(1, mid):
	ans += min(d[i], d[k - i])
print(2 * ans)


(n, k) = map(int, input().strip().split())
array = list(map(int, input().strip().split()))
array_k = [0] * k
result = 0
for i in range(n):
	array[i] = array[i] % k
	array_k[array[i]] += 1
zero = array_k[0]
result += zero // 2
tmp = 0
for i in range(1, k):
	tmp += min(array_k[i], array_k[len(array_k) - i])
result += tmp // 2
print(2 * result)


def f(l1, l2):
	(n, k) = l1
	cl = [0] * k
	for i in l2:
		cl[i % k] += 1
	p = cl[0] // 2
	p += sum([min(cl[i], cl[k - i]) for i in range(1, k) if i < k - i])
	p += 0 if k % 2 > 0 else cl[k // 2] // 2
	return p << 1
l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))
print(f(l1, l2))


import sys
LI = lambda : list(map(int, sys.stdin.readline().split()))
MI = lambda : map(int, sys.stdin.readline().split())
SI = lambda : sys.stdin.readline().strip('\n')
II = lambda : int(sys.stdin.readline())
(n, k) = MI()
a = {i: 0 for i in range(k + 1)}
for v in LI():
	a[v % k] += 1
ans = a[0] - 1 if a[0] % 2 else a[0]
for v in range(k // 2 + 1):
	if a[v] and a[k - v] and (k - v != v):
		ans += min(a[v], a[k - v]) * 2
	elif k - v == v:
		ans += a[v] - 1 if a[v] % 2 else a[v]
print(ans)


(n, k) = map(int, input().split())
sm = 0
l = [int(i) for i in input().split()]
l = [i % k for i in l]
from collections import defaultdict
d = defaultdict(int)
for i in l:
	if i == 0:
		if d[0] > 0:
			sm += 2
			d[0] = 0
		else:
			d[0] += 1
		continue
	if d[k - i] > 0:
		sm += 2
		d[k - i] -= 1
		d[i] = 0
	else:
		d[i] += 1
print(sm)


(n, k) = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
freq = [0] * k
ans = 0
for i in range(len(A)):
	cur = A[i] % k
	if cur == 0 and freq[0] != 0 or (cur != 0 and freq[k - cur] != 0):
		ans += 2
		if cur != 0:
			freq[k - cur] -= 1
		elif cur == 0:
			freq[0] -= 1
	else:
		freq[cur] += 1
print(ans)


def find_freq(a, rem, m):
	for i in a:
		rem[i % m] += 1

def main():
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	rem = [0] * m
	find_freq(a, rem, m)
	ans = rem[0] // 2
	if m % 2:
		mid = (m + 1) // 2
	else:
		mid = m // 2
	for i in range(1, mid):
		ans += min(rem[i], rem[m - i])
	if m % 2 == 0:
		ans += rem[m // 2] // 2
	print(ans * 2)
main()


(n, k) = list(map(int, input().split()))
candies = list(map(int, input().split()))
rests = [0 for i in range(k)]
for i in range(len(candies)):
	candies[i] %= k
	rests[candies[i]] += 1
pairs = rests[0] // 2 * 2
(i, j) = (1, k - 1)
while i <= j:
	if i != j:
		pairs += 2 * min(rests[i], rests[j])
	else:
		pairs += rests[i] // 2 * 2
	i += 1
	j -= 1
print(pairs)


inp = list(map(int, input().split(' ')))
n = inp[0]
k = inp[1]
d = list(map(int, input().split(' ')))
m = {}
for i in range(len(d)):
	dd = d[i]
	dd_k = dd % k
	if dd_k in m:
		m[dd_k] += 1
	else:
		m[dd_k] = 1
acc = 0
for key in m:
	if key == 0:
		acc += m[key] - m[key] % 2
	elif key < k / 2:
		m1 = m[key]
		m2 = 0
		if k - key in m:
			m2 = m[k - key]
		acc += min(m1, m2) * 2
	elif key == k / 2:
		acc += m[key] // 2 * 2
print(acc)


import sys
iinput = sys.stdin.readline
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
ans = [0] * k
for i in range(n):
	ans[a[i] % k] += 1
cnt = ans[0] // 2 * 2
if k % 2 == 0:
	cnt += ans[k // 2] // 2 * 2
for i in range(1, k // 2 + k % 2):
	cnt += 2 * min(ans[i], ans[k - i])
print(cnt)


(n, k) = map(int, input().split())
list_1 = [0 for i in range(k)]
temp = [int(i) % k for i in input().split()]
for i in range(k):
	list_1[i] = temp.count(i)
ans = 0
if k % 2:
	ans += list_1[0] // 2
	for i in range(1, k // 2 + 1):
		ans += min(list_1[i], list_1[k - i])
	print(ans * 2)
else:
	ans += list_1[0] // 2 + list_1[k // 2] // 2
	for i in range(1, k // 2):
		ans += min(list_1[i], list_1[k - i])
	print(ans * 2)


(n, k) = list(map(int, input().split()))
ans = [0] * k
a = list(map(int, input().split()))
for c in a:
	ans[c % k] += 1
kol = ans[0] - ans[0] % 2
for i in range(1, int(k / 2 + 0.5)):
	kol += min(ans[i], ans[k - i]) * 2
if k % 2 == 0:
	kol += ans[k // 2] - ans[k // 2] % 2
print(kol)


(n, k) = map(int, input().split())
D = list(map(int, input().split()))
D = [d % k for d in D]
from collections import defaultdict
d = defaultdict(lambda : 0)
ans = 0
for (i, e) in enumerate(D):
	if e != 0:
		if d[k - e] >= 1:
			ans += 1
			d[k - e] -= 1
		else:
			d[e] += 1
	elif d[0] >= 1:
		ans += 1
		d[0] -= 1
	else:
		d[0] += 1
print(ans * 2)


(n, k) = list(map(int, input().split()))
hm = {}
for i in input().split():
	t = int(i) % k
	if t in hm:
		hm[t] += 1
	else:
		hm[t] = 1
res = 0
for i in hm:
	if hm[i] == 0:
		continue
	if i == 0:
		if hm[i] > 1:
			res += hm[i] // 2
			hm[i] -= hm[i] // 2 * 2
	elif hm[i] > 0:
		t = k - i
		if t in hm:
			if t == i:
				res += hm[i] // 2
				hm[i] -= hm[i] // 2 * 2
			elif hm[t] > 0:
				mi = min(hm[i], hm[t])
				hm[i] -= mi
				hm[t] -= mi
				res += mi
print(res * 2)


def shift(x, idx, dir):
	value = x[idx]
	bound = 0
	idx += dir
	while 0 <= idx < len(x) and x[idx] == value:
		idx += dir
	return idx

def solution(n, k, x):
	r = []
	for elem in x:
		r.append(elem % k)
	r.sort()
	(L, R) = (0, len(r) - 1)
	cnt0 = 0
	while L <= R and r[L] == 0:
		cnt0 += 1
		L += 1
	ans = cnt0 - cnt0 % 2
	while L <= R:
		if r[L] + r[R] == k:
			if r[L] == r[R]:
				return ans + (R - L + 1) - (R - L + 1) % 2
			new_L = shift(r, L, 1)
			new_R = shift(r, R, -1)
			ans += 2 * min(new_L - L, R - new_R)
			(L, R) = (new_L, new_R)
		elif r[L] + r[R] < k:
			L = shift(r, L, 1)
		else:
			R = shift(r, R, -1)
	return ans
(n, k) = map(int, input().split())
x = list(map(int, input().split()))
print(solution(n, k, x))


(n, k) = map(int, input().split())
A = [int(x) % k for x in input().split()]
K = {i: 0 for i in range(k)}
for x in A:
	K[x] += 1
tot = K[0] // 2
for i in range(1, k // 2 + 1):
	x = min(K[i], K[k - i])
	tot += x if i != k - i else x // 2
print(tot * 2)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
d = {}
ans = 0
for i in a:
	d[i % k] = d.get(i % k, 0) + 1
for i in d:
	if i % k == k - i % k or i % k == 0:
		ans += d[i % k] // 2
	elif i % k < k / 2:
		ans += min(d.get(i % k, 0), d.get(k - i % k, 0))
print(ans * 2)


(m, k) = map(int, input().split())
l = [0] * 100
a = list(map(int, input().split()))
ans = 0
a.sort()
for i in range(m):
	if l[(k - a[i] % k) % k] == 0:
		l[a[i] % k] += 1
	else:
		ans += 2
		l[(k - a[i] % k) % k] -= 1
print(ans)


import sys
import math
from functools import reduce
import bisect

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

def getNM():
	return map(int, input().split())

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

def input():
	return sys.stdin.readline().rstrip()

def index(a, x):
	i = bisect.bisect_left(a, x)
	if i != len(a) and a[i] == x:
		return i
	return False
(n, k) = getNM()
arr = getList()
ost = [0] * k
for x in arr:
	ost[x % k] += 1
ans = 0
ans += ost[0] // 2
if k & 1:
	for i in range(1, k // 2 + 1):
		ans += min(ost[i], ost[k - i])
else:
	for i in range(1, k // 2):
		ans += min(ost[i], ost[k - i])
	ans += ost[k // 2] // 2
print(ans * 2)


(n, k) = map(int, input().split())
d = list(map(int, input().split()))
mod = dict()
for i in range(k):
	mod[i] = []
for i in range(n):
	if d[i] % k == 0:
		mod[d[i] % k].append(d[i])
	else:
		mod[k - d[i] % k].append(d[i])
ans = len(mod[0]) // 2
pair = set()
for i in range(1, k):
	pair.add((i, k - i))
	if i == k - i:
		ans += len(mod[i]) // 2
	else:
		x = len(pair)
		pair.add((k - i, i))
		if len(pair) > x:
			ans += min(len(mod[i]), len(mod[k - i]))
print(ans * 2)


import sys
import math
import collections
import bisect
import string

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_list():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_string():
	return sys.stdin.readline().strip()
for t in range(1):
	(n, k) = get_ints()
	arr = get_list()
	for i in range(n):
		arr[i] = arr[i] % k
	counter = collections.Counter(arr)
	ans = 0
	for i in counter:
		no = i
		rem = k - i
		if no == rem or rem == k:
			number = counter[no] // 2
			counter[i] -= number * 2
			ans += number * 2
		elif rem in counter:
			number = min(counter[no], counter[rem])
			counter[no] -= number
			counter[rem] -= number
			ans += 2 * number
	print(ans)


(n, k) = list(map(int, input().split()))
a = list(map(int, input().split()))
divs = {}
handled = [False] * k
for x in a:
	divs[x % k] = divs.get(x % k, 0) + 1
result = divs.get(0, 0) - divs.get(0, 0) % 2
for i in range(1, k):
	if not handled[i] and (not handled[k - i]):
		if i != k - i:
			result += 2 * min(divs.get(i, 0), divs.get(k - i, 0))
		else:
			result += divs.get(i, 0) - divs.get(i, 0) % 2
		handled[i] = handled[k - i] = True
print(result)


def ten():
	(n, k) = map(int, input().split())
	ar = map(int, input().split())
	cou = [0] * k
	ans = 0
	for i in ar:
		tmp = i % k
		if cou[(k - tmp) % k] > 0:
			cou[(k - tmp) % k] -= 1
			ans += 1
		else:
			cou[tmp] += 1
	print(ans * 2)
ten()


import re, math, decimal, bisect

def read():
	return input().strip()

def iread():
	return int(input().strip())

def viread():
	return [int(_) for _ in input().strip().split()]
import collections
(n, k) = viread()
boxes = collections.Counter([x % k for x in viread()])
i = 0
ans = boxes[0] - boxes[0] % 2
boxes[0] %= 2
for t in sorted(boxes.keys()):
	if t == 0:
		continue
	need = k - t
	while boxes[t] > 0:
		if need in boxes and (boxes[need] > 1 or (need != t and boxes[need] > 0)):
			ans += 2
			boxes[need] -= 1
			boxes[t] -= 1
		else:
			break
print(ans)


line = [int(i) for i in input().split(' ')]
n = line[0]
k = line[1]
boxes = [int(i) for i in input().split(' ')]
boxes = [box % k for box in boxes]
m = {}
for box in boxes:
	count = m.get(box, 0)
	m[box] = count + 1
res = 0
for box in boxes:
	if m.get(box) is not None and m.get(box) > 0:
		m[box] -= 1
		tmp = box if box == 0 else k - box
		if m.get(tmp) is not None and m.get(tmp) > 0:
			m[tmp] -= 1
			res += 2
		else:
			m[box] += 1
print(res)


def numofnum(a, info):
	counter = 0
	for i in range(len(info)):
		if info[i] == a:
			counter = counter + 1
	return counter
a = input()
b = input()
info = b.split(' ')
hi = a.split(' ')
counter = 0
for i in range(len(info)):
	info[i] = int(info[i]) % int(hi[1])
sum = 0
sum = sum + numofnum(0, info) // 2
if int(hi[1]) % 2 == 0:
	sum = sum + numofnum(int(hi[1]) / 2, info) // 2
	for i in range(1, int(int(hi[1]) / 2)):
		sum = sum + min(numofnum(i, info), numofnum(int(hi[1]) - i, info))
else:
	for i in range(1, int(int(hi[1]) // 2) + 1):
		sum = sum + min(numofnum(i, info), numofnum(int(hi[1]) - i, info))
print(sum * 2)


def stdin():
	return list(map(int, input().split()))
(n, k) = stdin()
candies = stdin()
count = [0] * k
for candie in candies:
	count[candie % k] += 1
ans = 0
for i in range(k // 2 + 1):
	j = (k - i) % k
	if i == j:
		count[i] //= 2
	ans += min(count[i], count[j])
print(ans * 2)


(n, k) = list(map(int, input().split()))
lis = list(map(int, input().split()))
d = {}
l = []
for i in lis:
	temp = i % k
	l.append(temp)
	if temp not in d:
		d[temp] = 1
	else:
		d[temp] += 1
ans = 0
for i in l:
	p = k - i
	if i == 0:
		if d[i] >= 2:
			ans += 2
			d[i] -= 2
			continue
	if p in d and d[p] > 0:
		if p == i:
			if d[p] >= 2:
				ans += 2
				d[i] -= 2
				continue
		elif d[p] >= 1 and d[i] >= 1:
			ans += 2
			d[p] -= 1
			d[i] -= 1
print(ans)


from sys import stdin
from sys import stdout
(n, k) = map(int, stdin.readline().split())
d = list(map(int, stdin.readline().split()))
a = [0] * k
for i in d:
	a[i % k] += 1
mid = a[0] // 2
for i in range((k - 1) // 2):
	mid += min(a[i + 1], a[k - 1 - i])
if not k & 1:
	mid += a[k // 2] // 2
print(mid * 2)


def fun():
	temp = []
	for i in range(n):
		temp.append(array[i] % k)
	x = int(temp.count(0) / 2) * 2
	temp.sort()
	index = 0
	for i in range(n):
		if temp[i] != 0:
			index = i
			break
	start = index
	end = n - 1
	while start < end:
		if temp[start] + temp[end] == k:
			x += 2
			start += 1
			end -= 1
		elif temp[start] + temp[end] > k:
			end -= 1
		else:
			start += 1
	return x
(n, k) = map(int, input().split())
array = list(map(int, input().split()))
print(fun())


(n, k) = list(map(int, input().strip().split()))
d = list(map(int, input().strip().split()))
mod_dict = dict()
for di in d:
	di_mod = di % k
	if di_mod in mod_dict:
		mod_dict[di_mod] += 1
	else:
		mod_dict[di_mod] = 1
tot_boxes = 0
for i in range(1, k):
	if i in mod_dict and k - i in mod_dict:
		if i == k - i:
			tot_boxes += int(mod_dict[i] / 2) * 2
		else:
			tot_boxes += min(mod_dict[i], mod_dict[k - i])
if 0 in mod_dict:
	tot_boxes += int(mod_dict[0] / 2) * 2
print(tot_boxes)


(n, k) = list(map(int, list(input().split(' '))))
boxes = list(map(int, list(input().split(' '))))
divisors = [0] * k
for b in boxes:
	divisors[b % k] += 1
result = 0
for i in range(0, k):
	if 2 * i % k == 0:
		result += 2 * (divisors[i] // 2)
		divisors[i] = divisors[i] % 2
for i in range(1, k // 2 + 1):
	if i == k - i:
		continue
	result += min(divisors[i], divisors[k - i]) * 2
print(result)


import sys
import math
import bisect

def main():
	(n, m) = map(int, input().split())
	A = [0] * m
	for a in list(map(int, input().split())):
		A[a % m] += 1
	ans = 0
	for i in range(m):
		j = (m - i) % m
		if j == i:
			ans += A[i] // 2 * 2
		elif j > i:
			ans += min(A[i], A[j]) * 2
	print(ans)
main()


from collections import defaultdict
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
d = defaultdict(int)
for i in a:
	d[i % k] += 1
ans = 0
for i in range(1, k // 2 + 1):
	if i == k - i:
		ans += d[i] // 2 * 2
	else:
		ans += min(d[i], d[k - i]) * 2
ans += d[0] // 2 * 2
print(ans)


def main():
	(n, k) = map(int, input().split())
	dd = [int(i) for i in input().split()]
	cntd = [0] * k
	for i in range(n):
		cntd[dd[i] % k] += 1
	ans = cntd[0] // 2
	if k % 2 == 0:
		ans += cntd[k // 2] // 2
	for i in range(1, (k + 1) // 2):
		ans += min(cntd[i], cntd[k - i])
	print(ans * 2)
main()


import math
import os
import random
import re
import sys
(n, k) = [int(i) for i in input().split()]
l = [int(i) for i in input().split()]
freq = [0] * k
for i in l:
	freq[i % k] += 1
ans = freq[0] // 2
if k % 2 == 0:
	ans += freq[k // 2] // 2
for i in range(1, (k + 1) // 2):
	x = min(freq[i], freq[k - i])
	ans += x
print(2 * ans)


(n, k) = map(int, input().split())
a = map(lambda x: int(x) % k, input().split())
f = {}
an = 0
for i in a:
	if -i in f and f[-i] > 0:
		an += 2
		f[-i] -= 1
	elif k - i in f and f[k - i] > 0:
		an += 2
		f[k - i] -= 1
	else:
		if i not in f:
			f[i] = 0
		f[i] += 1
print(an)


(n, k) = input().split(' ')
n = int(n)
k = int(k)
arr = input().split(' ')
arr = [int(a) for a in arr]
modTable = [0] * k
for a in arr:
	modTable[a % k] += 1
ans = 0
for i in range(0, k // 2 + 1):
	if i == (k - i) % k:
		ans += modTable[i] // 2
	else:
		ans += min(modTable[i], modTable[k - i])
print(2 * ans)


(x, y) = map(int, input().split())
z = list(map(int, input().split()))
total = 0
count = 0
for i in range(len(z)):
	z[i] = z[i] % y
freq = {}
for items in range(0, y):
	freq[items] = z.count(items)
for i in freq.keys():
	if i == 0:
		total = total + freq[i] // 2
	elif y - i == i:
		total = total + freq[i] // 2
	else:
		total = total + min(freq[i], freq[y - i]) // 2
		if min(freq[i], freq[y - i]) % 2 == 1:
			count = count + 0.5
print(2 * (total + int(count)))


(n, k) = [int(i) for i in input().split()]
arr = [int(i) % k for i in input().split()]
arr.sort()
ans = arr.count(0) - arr.count(0) % 2
for i in range(1, k // 2 + 1):
	if k - i == i:
		ans += arr.count(i) - arr.count(i) % 2
	else:
		ans += min(arr.count(i), arr.count(k - i)) * 2
print(ans)


def arr_scan():
	return list(map(int, input().split(' ')))
(n, k) = arr_scan()
box = arr_scan()
for i in range(n):
	box[i] %= k
box = sorted(box)
counter = {}
for i in box:
	if i in counter:
		counter[i] += 1
	else:
		counter[i] = 1
ans = 0
for key in counter.keys():
	v1 = counter[key]
	to_find = k - key
	if to_find == key or key == 0:
		ans += v1
		v1 %= 2
		ans -= v1
		counter[key] = v1
		continue
	if to_find in counter:
		v2 = counter[to_find]
		if v1 > v2:
			ans += v2 * 2
			v1 -= v2
			v2 = 0
		else:
			ans += v1 * 2
			v2 -= v1
			v1 = 0
		counter[key] = v1
		counter[to_find] = v2
print(ans)


(n, k) = map(int, input().split())
(*candies,) = map(lambda x: int(x) % k, input().split())
seen = []
from collections import Counter
c = Counter(candies)
ans = c[0] // 2
if k % 2:
	for i in range(1, k // 2 + 1):
		ans += min(c[i], c[k - i])
else:
	for i in range(1, k // 2):
		ans += min(c[i], c[k - i])
	ans += c[k // 2] // 2
print(ans * 2)


(n, m) = map(int, input().split())
l = map(int, input().split())
ans = {}
for e in l:
	try:
		ans[e % m] += 1
	except:
		ans[e % m] = 1
c = 0
for k in ans:
	if k == m - k % m or k == 0:
		if ans[k] % 2 != 0:
			c += ans[k] - 1
		elif ans[k] > 1:
			c += ans[k]
	else:
		try:
			qty = min(ans[k], ans[m - k % m])
			c += qty * 2
			ans[k] -= qty
			ans[m - k % m] -= qty
		except:
			pass
print(c)


import math
inp_1 = input().split()
n = int(inp_1[0])
k = int(inp_1[1])
remainers = [0] * k
boxes = input().split()
for b in boxes:
	remainers[int(b) % k] += 1
total_presents = 0
for i in range(0, int(k / 2) + 1):
	if i == 0 or i == k / 2:
		total_presents += 2 * int(remainers[i] / 2)
	else:
		total_presents += 2 * min(remainers[i], remainers[k - i])
print(total_presents)


import math
(n, k) = map(int, input().split())
d = list(map(int, input().split()))

def bruteforce(n, k, d):
	pairs = 0
	for i in range(n):
		if len(d) == 0:
			break
		c = d.pop()
		for (j, a) in enumerate(d):
			if (a + c) % k == 0:
				d.pop(j)
				pairs += 2
				break
	print(pairs)
	return pairs

def smart(n, k, d):
	d_k = {}
	for a in range(k):
		d_k[a] = 0
	for a in d:
		d_k[a % k] = d_k.get(a % k, 0) + 1
	total = int(d_k[0] / 2) * 2
	for i in range(1, k):
		boxes = int(min(d_k[i], d_k[k - i]))
		if i == k / 2:
			boxes = int(boxes / 2) * 2
		total += boxes
	print(total)
	return total
smart(n, k, d)


(n, k) = [int(i) for i in input().split()]
arr = [int(i) for i in input().split()]
temp = []
for ele in arr:
	temp.append(ele % k)
dct = {}
for ele in temp:
	if ele in dct:
		dct[ele] = dct[ele] + 1
	else:
		dct[ele] = 1
count = 0
for i in range(1, int(k / 2) + 1):
	if i not in dct:
		continue
	if k - i not in dct:
		continue
	if i == k - i:
		count = count + 2 * int(dct[i] / 2)
	else:
		count = count + 2 * min(dct[i], dct[k - i])
if 0 in dct:
	count = count + int(dct[0] / 2) * 2
print(count)


(n, k) = list(map(int, input().split()))
arr = list(map(int, input().split()))
temp = []
for i in arr:
	temp.append(i % k)
d = {}
for i in temp:
	if i in d:
		d[i] += 1
	else:
		d[i] = 1
if 0 in d:
	ans = d[0] // 2
else:
	ans = 0
if k % 2 == 0:
	f = 0
else:
	f = 1
for i in range(1, k // 2 + f):
	if i in d and k - i in d:
		x = min(d[i], d[k - i])
		d[i] -= x
		d[k - i] -= x
		ans += x
if k % 2 == 0 and k // 2 in d:
	ans += d[k // 2] // 2
print(ans * 2)


(n, k) = input().split()
n = int(n)
k = int(k)
d = []
d.extend(input().split())
db = 0
nd = []
ndb = {}
for i in range(len(d)):
	d[i] = int(d[i])
	if d[i] % k == 0:
		db += 1
	elif d[i] % k in ndb:
		ndb[d[i] % k] += 1
	else:
		ndb[d[i] % k] = 1
		nd.append(d[i] % k)
result = 2 * int(db / 2)
for i in range(len(nd)):
	if k == nd[i] * 2:
		result += 2 * int(ndb[nd[i]] / 2)
	elif k - nd[i] in nd:
		result += min(ndb[nd[i]], ndb[k - nd[i]])
print(result)


from collections import Counter
nk = list(map(int, input().split()))
(n, k) = (nk[0], nk[1])
di = list(map(lambda x: int(x) % k, input().split()))
count = Counter(di)
for i in range(k):
	if i not in count:
		count.update({i: 0})
gifts = count[0] // 2
if k % 2 == 0:
	gifts += count[k // 2] // 2
	gifts += sum(map(lambda i: min(count[i], count[k - i]), range(1, k // 2)))
else:
	gifts += sum(map(lambda i: min(count[i], count[k - i]), range(1, k // 2 + 1)))
print(gifts * 2)


(n, k) = list(map(int, input().split()))
d = list(map(int, input().split()))
lr = [0] * k
for i in range(n):
	lr[d[i] % k] += 1
mk = k // 2
ans = lr[0] // 2 * 2
for j in range(1, mk + 1):
	if j != k - j:
		ans += (lr[j] + lr[k - j] - abs(lr[j] - lr[k - j])) // 2 * 2
	else:
		ans += lr[j] // 2 * 2
print(ans)


(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
a = dict.fromkeys(range(k), 0)
count = 0
for i in range(n):
	a[arr[i] % k] += 1
for i in range((k + 1) // 2):
	if i == 0:
		count += a[0] // 2
		continue
	if a[i] <= a[k - i]:
		count += a[i]
	else:
		count += a[k - i]
if k % 2 == 0:
	count += a[k / 2] // 2
print(count * 2)


import sys
from bisect import bisect_left, bisect_right, insort
from collections import deque, Counter
from math import gcd, sqrt, factorial, ceil, log10, log2, floor
from itertools import permutations
from heapq import heappush, heappop, heapify
inf = float('inf')
mod = 1000000007

def factorial_p(n, p):
	ans = 1
	if n <= p // 2:
		for i in range(1, n + 1):
			ans = ans * i % p
	else:
		for i in range(1, p - n):
			ans = ans * i % p
		ans = pow(ans, p - 2, p)
		if n % 2 == 0:
			ans = p - ans
	return ans

def nCr_p(n, r, p):
	ans = 1
	while n != 0 or r != 0:
		(a, b) = (n % p, r % p)
		if a < b:
			return 0
		ans = ans * factorial_p(a, p) * pow(factorial_p(b, p), p - 2, p) * pow(factorial_p(a - b, p), p - 2, p) % p
		n //= p
		r //= p
	return ans

def prime_sieve(n):
	flag = n % 6 == 2
	sieve = bytearray((n // 3 + flag >> 3) + 1)
	for i in range(1, int(n ** 0.5) // 3 + 1):
		if not sieve[i >> 3] >> (i & 7) & 1:
			k = 3 * i + 1 | 1
			for j in range(k * k // 3, n // 3 + flag, 2 * k):
				sieve[j >> 3] |= 1 << (j & 7)
			for j in range(k * (k - 2 * (i & 1) + 4) // 3, n // 3 + flag, 2 * k):
				sieve[j >> 3] |= 1 << (j & 7)
	return sieve

def prime_list(n):
	res = []
	if n > 1:
		res.append(2)
	if n > 2:
		res.append(3)
	if n > 4:
		sieve = prime_sieve(n + 1)
		res.extend((3 * i + 1 | 1 for i in range(1, (n + 1) // 3 + (n % 6 == 1)) if not sieve[i >> 3] >> (i & 7) & 1))
	return res

def is_prime(n):
	if n < 5 or n & 1 == 0 or n % 3 == 0:
		return 2 <= n <= 3
	s = (n - 1 & 1 - n).bit_length() - 1
	d = n >> s
	for a in [2, 325, 9375, 28178, 450775, 9780504, 1795265022]:
		p = pow(a, d, n)
		if p == 1 or p == n - 1 or a % n == 0:
			continue
		for _ in range(s):
			p = p * p % n
			if p == n - 1:
				break
		else:
			return False
	return True

def all_factors(n):
	(small, large) = ([], [])
	for i in range(1, int(n ** 0.5) + 1, 2 if n & 1 else 1):
		if not n % i:
			small.append(i)
			large.append(n // i)
	if small[-1] == large[-1]:
		large.pop()
	large.reverse()
	small.extend(large)
	return small

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def input():
	return sys.stdin.readline().strip()
(n, k) = get_ints()
Arr = get_array()
myArr = [0] * k
for i in Arr:
	myArr[i % k] += 1
count = 0
i = 1
j = k - 1
if k & 1:
	while i <= k // 2:
		count += min(myArr[i], myArr[j])
		i += 1
		j -= 1
	count += myArr[0] // 2
	print(count * 2)
else:
	while i < k // 2:
		count += min(myArr[i], myArr[j])
		i += 1
		j -= 1
	count += myArr[0] // 2 + myArr[k // 2] // 2
	print(count * 2)


from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt, sin, cos, ceil, floor
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(1000000000)
INF = float('inf')
(YES, Yes, yes, NO, No, no) = ('YES', 'Yes', 'yes', 'NO', 'No', 'no')
(dy4, dx4) = ([0, 1, 0, -1], [1, 0, -1, 0])
(dy8, dx8) = ([0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1])

def inside(y, x, H, W):
	return 0 <= y < H and 0 <= x < W

def ceil(a, b):
	return (a + b - 1) // b

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def lcm(a, b):
	g = gcd(a, b)
	return a / g * b

def euclidean_distance(y1, x1, y2, x2):
	return sqrt((y1 - y2) ** 2 + (x1 - x2) ** 2)

def manhattan_distance(y1, x1, y2, x2):
	return abs(y1 - y2) + abs(x1 - x2)

def main():
	(N, K) = map(int, input().split())
	D = list(map(int, input().split()))
	m = [0] * K
	for d in D:
		m[d % K] += 1
	ans = 0
	for i in range(K):
		for j in range(K):
			if (i + j) % K == 0 and m[i] > 0 and (m[j] > 0):
				num = min(m[i], m[j])
				if i == j:
					num //= 2
				ans += num
				m[i] -= num
				m[j] -= num
	print(ans * 2)
main()


import sys
(n, k) = map(int, sys.stdin.readline().split())
l = list(map(int, sys.stdin.readline().split()))
for i in range(n):
	l[i] = l[i] % k
l2 = [0] * k
for i in l:
	l2[i] += 1
summ = l2[0]
summ = summ // 2 * 2
l2 = l2[1:]
length = len(l2)
if length == 1:
	summ += l2[0]
elif length % 2 == 0:
	z = length // 2
	for i in range(z):
		summ += min(l2[i], l2[length - 1 - i]) * 2
else:
	z = length // 2
	summ += l2[z] // 2 * 2
	for i in range(z):
		summ += min(l2[i], l2[length - 1 - i]) * 2
print(summ)


(N, K) = map(int, input().split())
L = list(map(lambda x: int(x) % K, input().split()))
F = [0 for i in range(K)]
s = 0
for l in L:
	F[l] += 1
for i in range(K // 2 + 1):
	a = (K - i) % K
	if i == a:
		s += F[i] // 2 * 2
	else:
		s += min(F[i], F[a]) * 2
print(s)


(n, k) = [int(x) for x in input().split()]
sweet = [int(x) for x in input().split()]
total = [0] * k
counter = 0
for item in sweet:
	total[item % k] += 1
for i in range(1, k // 2 + 1):
	if i == k // 2 and k % 2 == 0:
		counter += total[k // 2] // 2
	elif i != k - i:
		counter += min(total[i], total[k - i])
counter += total[0] // 2
print(counter * 2)


from collections import Counter
(n, k) = (int(i) for i in input().split())
candies = Counter((int(i) % k for i in input().split()))
pairs = candies[0] // 2 * 2
for i in range(1, k):
	j = k - i
	pairs += min(candies[i], candies[j])
if k & 1 == 0:
	if candies[k // 2] & 1:
		pairs -= 1
print(pairs)


(n, k) = map(int, input().split())
candies = list(map(int, input().split()))
div = [0 for i in range(k)]
for i in candies:
	div[i % k] += 1
res = div[0] // 2 * 2
if k % 2 == 1:
	c = k // 2 + 1
else:
	c = k // 2 + 1
for i in range(1, c):
	res += 2 * min(div[i], div[k - i]) if i != k - i else div[i] // 2 * 2
print(res)


(n, k) = input().split()
n = int(n)
k = int(k)
divs = [0] * k
cnt = 0
c = input().split()
for i in c:
	divs[int(i) % k] += 1
while divs[0] > 1:
	divs[0] -= 2
	cnt += 1
if k % 2 == 0:
	while divs[k // 2] > 1:
		divs[k // 2] -= 2
		cnt += 1
for i in range(1, len(divs)):
	if i == k // 2 and k % 2 == 0:
		continue
	while divs[i] > 0 and divs[-i] > 0:
		divs[i] -= 1
		divs[-i] -= 1
		cnt += 1
print(cnt * 2)


lis = [0] * 100
(n, k) = map(int, input().split())
list = list(map(int, input().split()))
for i in list:
	lis[i % k] += 1
i = 1
j = k - 1
ans = 0
if k == 2:
	ans = ans + (lis[0] // 2 + lis[1] // 2)
else:
	ans += lis[0] // 2
	while i <= j:
		if i != j:
			ans += min(lis[i], lis[j])
		else:
			ans += lis[i] // 2
		i += 1
		j -= 1
print(ans * 2)


from collections import Counter
import sys
(n, k) = [int(x) for x in input().split()]
d = [int(x) % k for x in input().split()]
if k == 1:
	print(n // 2 * 2)
	sys.exit()
c = Counter(d)
count = 0
if k % 2:
	for num in c.keys():
		if num == 0:
			count += c[num] // 2 * 2
			continue
		count += min(c[num], c[k - num])
else:
	for num in c.keys():
		if num == 0:
			count += c[num] // 2 * 2
			continue
		if num == k // 2:
			count += c[num] // 2 * 2
		else:
			count += min(c[num], c[(k - num) % k])
print(count)


n = input().split()
k = int(n[1])
n = int(n[0])
a = input().split()
for i in range(len(a)):
	a[i] = int(a[i])
reminders = [0] * k
for i in range(n):
	reminders[a[i] % k] += 1
result = reminders[0] // 2 * 2
for i in range(1, k // 2 + 1):
	if i != k - i:
		if reminders[i] < reminders[k - i]:
			result = result + reminders[i] * 2
		else:
			result = result + reminders[k - i] * 2
	else:
		result = result + reminders[i] // 2 * 2
print(result)


import sys
line = sys.stdin.readline().strip().split()
n = int(line[0])
k = int(line[1])
d = sys.stdin.readline().strip().split()
A = [0] * k
for i in range(0, n):
	j = int(d[i]) % k
	A[j] = A[j] + 1
ans = 0
ans = ans + 2 * (A[0] // 2)
A[0] = 0
if k % 2 == 0:
	ans = ans + 2 * (A[k // 2] // 2)
	A[k // 2] = 0
for i in range(1, k):
	m = min([A[i], A[k - i]])
	ans = ans + 2 * m
	A[i] = A[i] - m
	A[k - i] = A[k - i] - m
print(ans)


(n, k) = list(map(int, input().split()))
a = list(map(int, input().split()))
b = [0 for i in range(k)]
for i in a:
	b[i % k] += 1
(p, q) = (1, k - 1)
l = 0
while p <= q:
	if p == q:
		l += min(b[p], b[q]) - min(b[p], b[q]) % 2
	else:
		l += min(b[p], b[q]) * 2
	p = p + 1
	q = q - 1
l += b[0] - b[0] % 2
print(l)


from collections import defaultdict
(n, k) = map(int, input().split())
ds = list(map(int, input().split()))
items = defaultdict(int)
for d in ds:
	items[d % k] += 1
cnt = items[0] // 2
(i, j) = (1, k - 1)
while j >= i:
	if i == j:
		cnt += items[i] // 2
	else:
		cnt += min(items[i], items[j])
	(i, j) = (i + 1, j - 1)
print(cnt * 2)


from sys import exit, setrecursionlimit
setrecursionlimit(10 ** 6)
inn = lambda : input().strip()
mapp_m1 = lambda : map(lambda x: int(x) - 1, inn().split(' '))
mapp = lambda : map(int, inn().split(' '))
(N, K) = mapp()
cd = list(mapp())
if K == 1:
	print(len(cd) - len(cd) % 2)
	exit()
for (i, a) in enumerate(cd):
	cd[i] %= K
from collections import Counter
count = Counter(cd)
answer = 0
for key in count:
	if key == K - key or key == 0:
		continue
	else:
		answer += min(count[key], count[K - key])
if K % 2 == 0:
	answer += count[K // 2] - count[K // 2] % 2
answer += count[0] - count[0] % 2
print(answer)


(n, k) = map(int, input().split())
lis = list(map(int, input().split()))
has = [0] * 150
ans = 0
for i in lis:
	has[i % k] += 1
ans += has[0] - has[0] % 2
for i in range(1, k):
	if i != k - i:
		ans += min(has[i], has[k - i]) * 2
	else:
		ans += has[i] - has[i] % 2
	has[i] = 0
	has[k - i] = 0
print(ans)


(cnt_box, cnt_girls) = map(int, input().split())
cnt_candy = [int(x) for x in input().split()]
arr = [0] * 100
for i in cnt_candy:
	arr[i % cnt_girls] += 1
counter = 0
for i in range(1, cnt_girls // 2 + 1):
	if i * 2 == cnt_girls:
		continue
	a = min(arr[i], arr[cnt_girls - i])
	counter += a
counter += arr[0] // 2
if cnt_girls % 2 == 0:
	counter += arr[cnt_girls // 2] // 2
print(counter * 2)


(n, k) = map(int, input().split())
d = [int(x) for x in input().split()]
r = {}
for dd in d:
	r[dd % k] = r.get(dd % k, 0) + 1
res = r.get(0, 0) // 2
for i in range(1, k // 2 + k % 2):
	res += min(r.get(i, 0), r.get(k - i, 0))
if k % 2 == 0:
	res += r.get(k // 2, 0) // 2
print(2 * res)


(n, k) = map(int, input().split())
d = list(map(lambda x: x % k, map(int, input().split())))
cnt = 0
for i in range(k // 2 + 1):
	if i == 0 or i == k / 2:
		cnt += 2 * (d.count(i) // 2)
	else:
		cnt += 2 * min(d.count(i), d.count(k - i))
print(cnt)


(n, k) = tuple(map(int, input().strip().split(' ')))
numbers = tuple(map(int, input().strip().split(' ')))
l = []
for i in range(k):
	l.append(0)
for i in numbers:
	l[i % k] += 1
s = l[0] // 2 * 2
import math
for g in range(1, math.ceil(k / 2)):
	s = s + min(l[g], l[k - g]) * 2
if k % 2 == 0:
	s = s + l[k // 2] // 2 * 2
print(s)


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
new_list = []
j = 0
while j < k:
	new_list.append(0)
	j += 1
for i in l:
	j = i % k
	new_list[j] += 1
sum = 0
j = 0
k1 = int(k / 2 + 1)
while j < k1:
	if j == 0 or k - j == j:
		sum = sum + int(new_list[j] / 2)
	elif new_list[k - j] > new_list[j]:
		sum += new_list[j]
	else:
		sum += new_list[k - j]
	j += 1
print(sum * 2)


from collections import Counter
(n, k) = map(int, input().split())
a = [int(o) for o in input().split()]
for i in range(n):
	a[i] = a[i] % k
d = dict(Counter(a))
ans = 0
try:
	ans += d[0] // 2
except:
	ans += 0
for i in d.keys():
	j = k - i
	if i != 0:
		if i != j:
			try:
				ans += min(d[i], d[j])
				d[i] = 0
			except:
				ans += 0
		else:
			ans += min(d[i], d[j]) // 2
			d[i] = 0
print(ans * 2)


(n, k) = map(int, input().split())
d = list(map(int, input().split()))
occ = [0] * (k + 1)
for g in d:
	occ[g % k] += 1
ans = occ[0] // 2 * 2
for i in range(1, (k + 1) // 2):
	ans += min(occ[i], occ[k - i]) * 2
if k % 2 == 0:
	ans += occ[k // 2] // 2 * 2
print(ans)


def func(params):
	(n, k) = params[0]
	nos = params[1]
	nos = map(lambda x: x % k, nos)
	rmdr = dict()
	for i in range(k):
		rmdr[i] = 0
	for n in nos:
		rmdr[n] += 1
	max_boxes = 0
	for (r, c) in rmdr.items():
		if r == 0:
			max_boxes += c if c % 2 == 0 else c - 1
		elif r < k / 2:
			max_boxes += 2 * min(c, rmdr[k - r])
		elif r == k / 2:
			max_boxes += c if c % 2 == 0 else c - 1
	print(max_boxes)
params = []
params.append(list(map(int, input().split())))
params.append(list(map(int, input().split())))
func(params)


(n, k) = map(int, input().split())
candies = list(map(int, input().split()))
candies = [x % k for x in candies]
nums = {}
total = 0
for c in candies:
	if (k - c) % k in nums and nums[(k - c) % k] > 0:
		total += 2
		nums[(k - c) % k] -= 1
	else:
		nums[c] = nums.get(c, 0) + 1
print(total)


from math import ceil
(n, k) = map(int, input().split())
d = list(map(int, input().split()))
packs = [0] * k
for i in d:
	packs[i % k] += 1
counter = packs[0] // 2
if k % 2 == 0:
	counter += packs[k // 2] // 2
for i in range(1, ceil(k / 2)):
	counter += min(packs[i], packs[k - i])
print(counter * 2)


from sys import stdin
from collections import *

def arr_inp(n):
	if n == 1:
		return [int(x) for x in stdin.readline().split()]
	elif n == 2:
		return [float(x) for x in stdin.readline().split()]
	else:
		return list(stdin.readline()[:-1])
(n, k) = arr_inp(1)
(a, mem) = (arr_inp(1), Counter())
for i in range(n):
	mem[a[i] % k] += 1
ans = mem[0] - mem[0] % 2
for i in range(1, k // 2 + 1):
	mi = min(mem[i], mem[k - i])
	ans += mi * 2 if i != k - i else mi - mi % 2
print(ans)


(n, k) = map(int, input().split())
a = [0] * k
for x in map(int, input().split()):
	a[x % k] += 1
(ans, l, r) = (a[0] // 2, 1, k - 1)
while l < r:
	ans += min(a[l], a[r])
	l += 1
	r -= 1
if k % 2 == 0:
	ans += a[k // 2] // 2
print(ans * 2)


(n, k) = list(map(int, input().split()))
a = list(map(int, input().split()))
d = [0] * k
for i in range(n):
	d[a[i] % k] += 1
num = 0
for i in range(k):
	if k - i < i:
		break
	if i == 0:
		num += d[i] // 2
	elif i == k - i:
		num += d[i] // 2
	else:
		num += min(d[i], d[k - i])
print(num * 2)


(n, k) = map(int, input().strip().split())
A = map(int, input().strip().split())
hashm = {}
for a in A:
	try:
		hashm[a % k] += 1
	except:
		hashm[a % k] = 1
count = 0
for a in hashm.keys():
	if a % k == 0 or a == k - a:
		count += int(hashm[a] / 2) * 2
	else:
		try:
			z = min(hashm[a], hashm[k - a])
			hashm[k - a] = 0
			count += z * 2
		except:
			pass
print(count)


(n, k) = [int(x) for x in input().split(' ')]
boxes = [int(x) for x in input().split(' ')]
a = [0] * k
total = 0
for box in boxes:
	m = box % k
	if m == 0:
		index = 0
	else:
		index = k - m
	if a[index] >= 1:
		total += 1
		a[index] -= 1
	else:
		a[m] += 1
print(total * 2)


import sys
import collections
input = sys.stdin.readline
(N, K) = map(int, input().strip().split())
A = list(map(int, input().strip().split()))
cnts = collections.Counter((a % K for a in A))
pairs = 0
vals = [[key, cnts[key]] for key in cnts]
vals.sort(key=lambda x: x[0])
for i in range(len(vals)):
	for j in range(len(vals)):
		if vals[i][1] != None and vals[j][1] != None:
			if (vals[i][0] + vals[j][0]) % K == 0:
				if i == j and vals[i][0] == vals[j][0] == 0:
					pairs += vals[i][1] if vals[i][1] % 2 == 0 else vals[i][1] - 1
					vals[i][1] = None
					continue
				pairs += min(vals[i][1], vals[j][1])
print(pairs if pairs % 2 == 0 else pairs - 1)


from collections import defaultdict

def main():
	d = defaultdict(int)
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	for ele in arr:
		d[ele % k] += 1
	m = 0
	for key in list(d.keys()):
		if key == 0:
			if d[key] % 2 == 0:
				m += d[key]
			else:
				m += d[key] - 1
		elif k - key == key:
			if d[key] % 2 == 0:
				m += d[key]
			else:
				m += d[key] - 1
		else:
			l = min(d[key], d[k - key])
			m += 2 * l
			d[key] -= l
			d[k - key] -= l
	print(m)
main()


(n, k) = map(int, input().split())
a = [int(x) for x in input().split()]
b = [0] * k
for c in a:
	b[c % k] += 1
kk = b[0] - b[0] % 2
for i in range(1, int(k / 2 + 0.5)):
	kk += min(b[i], b[k - i]) * 2
if k % 2 == 0:
	kk += b[k // 2] - b[k // 2] % 2
print(kk)


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
re = [0] * 101
for i in range(n):
	re[l[i] % k] += 1
m = 0
for i in range(n):
	a = l[i] % k
	if 2 * a == k:
		if re[k - a] >= 2 and a != 0:
			m = m + 2
			re[k - a] = re[k - a] - 2
	elif re[k - a] >= 1 and a != 0 and (re[a] >= 1):
		m = m + 2
		re[k - a] = re[k - a] - 1
		re[a] = re[a] - 1
	elif a == 0 and re[0] >= 2:
		m = m + 2
		re[0] = re[0] - 2
print(m)


arr = input()
arr2 = input()
(N, K) = [int(x) for x in arr.split(' ')]
arr = [int(x) for x in arr2.split(' ')]
remain = [0] * K
for num in arr:
	r = num % K
	remain[r] += 1
res = 0
res += remain[0] // 2 * 2
left = 1
right = K - 1
while left <= right:
	if left == right:
		res += remain[left] // 2 * 2
	else:
		res += min(remain[left], remain[right]) * 2
	left += 1
	right -= 1
print(res)


from collections import Counter

def main():
	(n, k) = map(int, input().split())
	d = list(map(int, input().split()))
	counter = Counter()
	for x in d:
		counter[x % k] += 1
	ret = counter[0] // 2 * 2
	for i in range(1, k):
		if i != k - i:
			ret += min(counter[i], counter[k - i])
		else:
			ret += counter[i] // 2 * 2
	print(ret)

def __starting_point():
	main()
__starting_point()


(n, k) = map(int, input().split())
p = list(map(int, input().split()))
import collections
s = collections.defaultdict(int)
for i in p:
	s[i % k] += 1
tot = 0
tot += s[0] - s[0] % 2
for j in range(1, k):
	if k % 2 == 0 and j == k / 2:
		tot += s[j] - s[j] % 2
	else:
		tot += min(s[j % k], s[(k - j) % k])
print(tot)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
for i in range(n):
	a[i] = a[i] % k
c = [0] * k
for i in range(n):
	c[a[i]] += 1
co = c[0] // 2 * 2
if k % 2 == 1:
	for i in range(1, k // 2 + 1):
		co += min(c[i], c[k - i]) * 2
elif k % 2 == 0:
	for i in range(1, k // 2):
		co += min(c[i], c[k - i]) * 2
	co += c[k // 2] // 2 * 2
print(co)


(n, k) = [int(i) for i in input().split()]
boxes = [int(i) for i in input().split()]
candies = [0] * k
for i in boxes:
	candies[i % k] += 1
gift = candies[0] // 2 * 2
left = 1
right = k - 1
while left <= right:
	if left == right:
		if candies[left] % 2 == 0:
			gift += candies[left]
		else:
			gift += candies[left] - 1
	elif (left + right) % k == 0:
		temp = min(candies[left], candies[right])
		candies[left] -= temp
		candies[right] -= temp
		gift += 2 * temp
	left += 1
	right -= 1
print(gift)


import sys
(n, k) = [int(s) for s in input().split()]
array = [int(s) for s in input().split()]
counter = [0] * k
for i in range(len(array)):
	counter[array[i] % k] += 1
count = counter[0] // 2 * 2
for i in range(1, len(counter) // 2 + 1):
	if i == len(counter) - i:
		count += counter[i] // 2 * 2
		continue
	count += min(counter[i], counter[-i]) * 2
print(count)
sys.exit(0)


from sys import stdin

def main():
	(n, k) = [int(x) for x in stdin.readline().strip().split()]
	d = {0: 0}
	boxes = [int(x) % k for x in stdin.readline().strip().split()]
	for box in boxes:
		if not box in d:
			d[box] = 0
		d[box] += 1
	total = 0
	for key in d.keys():
		comp = k - key
		if comp in d:
			take = min(d[key], d[comp])
			take = take // 2 if comp * 2 == k else take
			total += take
			d[key] -= take
			d[comp] -= take
	print(total * 2 + d[0] // 2 * 2)
main()


from collections import Counter as C
(n, k) = map(int, input().split())
l = [int(x) % k for x in input().split()]
c = C(l)
res = 0
for i in range(k):
	j = -i % k
	(vi, vj) = (c.get(i, 0), c.get(j, 0))
	if i == j:
		res += vi // 2
	else:
		res += min(vi, vj)
	c[i] = 0
print(res * 2)


from collections import defaultdict as dd
(n, k) = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
dic = dd(int)
for i in range(n):
	dic[a[i] % k] += 1
ans = 0
ans = dic[0] // 2
if k % 2 == 0:
	ans += dic[k // 2] // 2
for i in range(1, (k + 1) // 2):
	reqd = k - i
	ans += min(dic[i], dic[reqd])
print(ans * 2)


freq = [0] * 100
(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
for i in range(n):
	freq[arr[i] % k] += 1
ans = 0
for i in range(100):
	for j in range(100):
		if (i + j) % k == 0:
			y = min(freq[i], freq[j])
			if i == j:
				y //= 2
			ans += y
			freq[i] = max(freq[i] - y, 0)
			freq[j] = max(freq[j] - y, 0)
print(2 * ans)


import math
(n, k) = map(int, input().split())
l = list(map(int, input().split()))
rem = [0] * k
for i in range(n):
	r = l[i] % k
	rem[r] += 1
ans = 0
ans += rem[0] // 2
if k % 2 == 0:
	ans += rem[k // 2] // 2
for i in range(1, (k + 1) // 2):
	ans += min(rem[i], rem[k - i])
print(ans * 2)


from collections import Counter

def candies(ct, k):
	n = ct[0] // 2
	if k % 2 == 0:
		n += ct[k // 2] // 2
	for (key, v) in sorted(ct.items()):
		if key == 0:
			continue
		if key >= k / 2:
			break
		n += min(v, ct[k - key])
	print(n * 2)

def main():
	(n, k) = map(int, input().split())
	ct = Counter(map(lambda x: int(x) % k, input().split()))
	candies(ct, k)
main()


(n, k) = list(map(int, input().split()))
l = list(map(int, input().split()))
d = {}
for i in range(k):
	d[i] = 0
for i in range(len(l)):
	l[i] = l[i] % k
	d[l[i]] += 1
s = 0
s += d[0] // 2
for i in range(1, k // 2):
	s += min(d[i], d[k - i])
if k % 2 == 0:
	s += d[k // 2] // 2
elif k != 1:
	s += min(d[k // 2], d[k - k // 2])
print(s * 2)


GI = lambda : int(input())
GIS = lambda : map(int, input().split())
LGIS = lambda : list(GIS())

def main():
	(n, k) = GIS()
	mods = [0] * k
	for d in GIS():
		mods[d % k] += 1
	r = 0
	for i in range(k):
		ii = (k - i) % k
		if i == ii:
			add = mods[i] - mods[i] % 2
		else:
			add = min(mods[i], mods[ii]) * 2
		r += add
		mods[i] = mods[ii] = 0
	print(r)
main()


def solve(boxes, girls, seq):
	remainder = [0] * 100
	ans = 0
	for x in seq:
		remainder[x % girls] += 1
	ans += remainder[0] // 2
	index = 1
	while index <= girls // 2:
		find = girls - index
		if find == index:
			ans += remainder[find] // 2
		else:
			ans += min(remainder[index], remainder[find])
		index += 1
	return ans * 2
(b, g) = list(map(int, input().split()))
seq = list(map(int, input().split()))
print(solve(b, g, seq))


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
ch = [0] * (k + 1)
for x in l:
	ch[x % k] += 1
ans = ch[0] // 2 + ch[k // 2 if k % 2 == 0 else -1] // 2
for i in range(1, (k + 1) // 2):
	ans += min(ch[i], ch[-i - 1])
print(ans * 2)


a = [int(s) for s in input().split()]
n = a[0]
k = a[1]
d = [int(s) for s in input().split()]
for i in range(n):
	d[i] = d[i] % k
a2 = [0] * k
for j in range(n):
	a2[d[j]] += 1
mid = k // 2
s = a2[0] // 2 * 2
for i in range(1, mid + 1):
	if i != k - i:
		s += min(a2[i], a2[k - i]) * 2
	else:
		a2[i] = a2[i] // 2 * 2
		s += min(a2[i], a2[k - i])
print(s)


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
c = [0] * k
m = 0
for i in l:
	c[i % k] += 1
	if m < i % k:
		m = i % k
ct = 0
for i in range(0, m + 1):
	if c[i] == 0:
		continue
	if i == 0:
		ct += c[i] // 2 * 2
		c[i] = 0
	elif i == k / 2 and k % 2 == 0:
		ct += c[i] // 2 * 2
		c[i] = 0
	elif c[k - i] > 0:
		m = min(c[i], c[k - i])
		ct += m * 2
		c[i] -= m
		c[k - i] -= m
print(ct)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
b = [0 for _ in range(k)]
count = 0
for i in a:
	if i % k == 0:
		count += 1
	b[i % k] += 1
count = count // 2
for i in range(1, k):
	if i * 2 == k:
		count += b[i] // 2
	else:
		count += min(b[i], b[len(b) - i])
	b[i] = 0
	b[len(b) - i] = 0
print(count * 2)


import sys
from collections import Counter

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

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

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7
(N, K) = MAP()
A = LIST()
C = Counter()
for i in range(N):
	C[A[i] % K] += 1
ans = C[0] // 2
del C[0]
if K % 2 == 0:
	ans += C[K // 2] // 2
	del C[K // 2]
for k in sorted(C.keys()):
	if k > K // 2:
		break
	ans += min(C[k], C[K - k])
print(ans * 2)


(n, k) = list(map(int, input().split()))
arr = list(map(int, input().split()))
div = {}
pair = 0
for i in arr:
	rem = i % k
	if k - rem in div.keys():
		div[k - rem] -= 1
		if div[k - rem] == 0:
			del div[k - rem]
		pair += 2
	else:
		div[rem] = div.get(rem, 0) + 1
zero = div.get(0, 0) if div.get(0, 0) % 2 == 0 else div.get(0, 0) - 1
kk = div.get(k, 0) if div.get(k, 0) % 2 == 0 else div.get(k, 0) - 1
pair += zero + kk
print(pair)


def fastio():
	import sys
	from io import StringIO
	from atexit import register
	global input
	sys.stdin = StringIO(sys.stdin.read())
	input = lambda : sys.stdin.readline().rstrip('\r\n')
	sys.stdout = StringIO()
	register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()
MOD = 10 ** 9 + 7
I = lambda : list(map(int, input().split()))
(n, k) = I()
l = I()
a = [0] * 105
for i in l:
	a[i % k] += 1
ans = 0
ans += 2 * (a[0] // 2)
for i in range(1, k):
	if i == k - i:
		ans += 2 * (a[i] // 2)
		continue
	ans += min(a[i], a[k - i])
print(ans)


x = list(map(int, input().split()))
y = list(map(int, input().split()))
(n, k) = (x[0], x[1])
z = [i % k for i in y]
s = [0] * k
for i in z:
	s[i] += 1
t = 0
if k % 2 == 0:
	for i in range(int(k / 2) + 1):
		if i == 0:
			t += s[0] // 2
		elif i == int(k / 2):
			t += s[int(k / 2)] // 2
		else:
			t += min(s[i], s[-i])
else:
	for i in range(int(k / 2) + 1):
		if i == 0:
			t += s[0] // 2
		else:
			t += min(s[i], s[-i])
print(t * 2)


import sys
import bisect
from math import ceil
input = sys.stdin.readline
(n, k) = map(int, input().split())
arr = [i % k for i in list(map(int, input().split()))]
arr.sort()
c = (bisect.bisect_right(arr, 0) - bisect.bisect_left(arr, 0)) // 2
if not k % 2:
	c += (bisect.bisect_right(arr, k // 2) - bisect.bisect_left(arr, k // 2)) // 2
c *= 2
for i in range(1, ceil(k / 2)):
	c += min(bisect.bisect_right(arr, i) - bisect.bisect_left(arr, i), bisect.bisect_right(arr, k - i) - bisect.bisect_left(arr, k - i)) * 2
print(c)


R = lambda : map(int, input().split())
(n, k) = R()
L = list(R())
P = []
for i in L:
	P.append(i % k)
C = [0] * k
for i in P:
	C[i] += 1
res = C[0] - 1 if C[0] % 2 else C[0]
(i, j) = (1, k - 1)
while i <= j:
	if i == j:
		if C[i] % 2:
			res += C[i] - 1
		else:
			res += C[i]
	else:
		mi = min(C[i], C[j])
		res += mi * 2
	i += 1
	j -= 1
print(res)


(n, k) = [int(i) for i in input().split()]
d = [int(i) for i in input().split()]
modulo = []
for i in range(k):
	modulo.append(0)
for cadeau in d:
	modulo[cadeau % k] += 1
res = 0
res += modulo[0] // 2
for i in range(1, k // 2 + 1):
	if i != k - i:
		res += min(modulo[i], modulo[k - i])
	else:
		res += modulo[i] // 2
print(2 * res)


def main():
	(n, k) = list(map(int, input().split()))
	candy = list(map(int, input().split()))
	candies = []
	zeroes = 0
	for i in candy:
		mod = i % k
		if mod == 0:
			zeroes += 1
		else:
			candies.append(mod)
	candies.sort()
	boxes = zeroes // 2
	candy_dict = {}
	for i in candies:
		if i not in list(candy_dict.keys()):
			candy_dict[i] = 1
		else:
			candy_dict[i] += 1
	for i in candy_dict:
		if candy_dict[i] > 0:
			if k - i in list(candy_dict.keys()):
				if candy_dict[k - i] > 0:
					if i == k - i:
						box = candy_dict[i] // 2
						candy_dict[i] = candy_dict[i] % 2
					else:
						box = min(candy_dict[i], candy_dict[k - i])
						candy_dict[i] -= box
						candy_dict[k - i] -= box
					boxes += box
	print(2 * boxes)
main()


import math
(n, k) = [int(x) for x in input().split(' ')]
d = [int(x) % k for x in input().split(' ')]
d_dict = {}
for i in range(k):
	d_dict[i] = 0
for b in d:
	d_dict[b] += 1
ans = 0
for i in range(1, math.ceil(k / 2)):
	ans += min(d_dict[i], d_dict[k - i])
if k % 2 == 0:
	ans += d_dict[k // 2] // 2
ans += d_dict[0] // 2
print(2 * ans)


(n, k) = map(int, input().split(' '))
d = list(map(int, input().split(' ')))
res = 0
for i in range(n):
	d[i] = d[i] % k
res += d.count(0) // 2 * 2
if k % 2 == 0:
	res += d.count(k // 2) // 2 * 2
if k % 2 == 0:
	for i in range(1, k // 2):
		res += min(d.count(i), d.count(k - i)) * 2
else:
	for i in range(1, k // 2 + 1):
		res += min(d.count(i), d.count(k - i)) * 2
print(res)


import math
import time
from collections import defaultdict, deque
from sys import stdin, stdout
from bisect import bisect_left, bisect_right
(n, k) = map(int, stdin.readline().split())
a = list(map(int, stdin.readline().split()))
rem = [0] * k
for i in a:
	rem[i % k] += 1
ans = 0
ans += rem[0] // 2
if k % 2 == 0:
	ans += rem[k // 2] // 2
	for i in range(1, k // 2):
		ans += min(rem[i], rem[k - i])
else:
	for i in range(1, k // 2 + 1):
		ans += min(rem[i], rem[k - i])
print(ans * 2)


I = lambda : map(int, input().split())
(n, k) = I()
l = list(I())
for i in range(n):
	if l[i] >= k:
		xs = l[i] // k
		ys = k * xs
		l[i] = l[i] - ys
d = dict()
for i in range(k):
	d[i] = 0
for i in l:
	d[i] += 1
c = 0
if k & 1 == 0:
	bs = d[k // 2] // 2
	c += bs
	ks = k // 2
else:
	ks = k // 2 + 1
for i in range(ks):
	if i == 0:
		bs = d[i] // 2
		c += bs
	else:
		bs = min(d[i], d[k - i])
		c += bs
print(c * 2)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
cnt = 100 * [0]
for x in a:
	cnt[x % k] += 1
ans = cnt[0] // 2 * 2
if k % 2 == 0:
	ans += cnt[k // 2] // 2 * 2
for i in range(1, k):
	if k % 2 == 0 and i == k // 2:
		continue
	mn = min(cnt[i], cnt[k - i])
	cnt[i] -= mn
	cnt[k - i] -= mn
	ans += mn * 2
print(ans)


def go():
	(n, k) = map(int, input().split(' '))
	a = [int(i) for i in input().split(' ')]
	d = {}
	answer = 0
	for x in a:
		m = x % k
		complement = k - m if m != 0 else 0
		if complement in d:
			answer += 2
			d[complement].pop()
			if len(d[complement]) == 0:
				d.pop(complement)
		else:
			d.setdefault(m, [])
			d[m].append(None)
	return answer
print(go())


(n, k) = map(int, input().split())
a1 = list(map(int, input().split()))
result = [0] * k
for i in a1:
	result[i % k] += 1
ans = 0
for i in range(1, k):
	if i == k - i:
		val = result[i] // 2
		result[i] -= val
	else:
		val = min(result[i], result[k - i])
		result[i] -= val
		result[k - i] -= val
	ans += val
ans += result[0] // 2
print(ans * 2)


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
nl = [0 for i in range(k)]
for i in l:
	nl[i % k] += 1
count = 0
for i in range(k // 2 + 1):
	if i == 0 or i == k - i:
		count += nl[i] // 2 * 2
	else:
		count += min(nl[i], nl[k - i]) * 2
print(count)


from math import *
(n, k) = list(map(int, input().split()))
arr = list(map(int, input().split()))
for i in range(n):
	arr[i] = arr[i] % k
count = [0] * k
for item in arr:
	count[item] += 1
maxi = count[0] // 2
index = k // 2
if k % 2 != 0:
	for i in range(1, index + 1):
		maxi += min(count[i], count[k - i])
else:
	for i in range(1, index):
		maxi += min(count[i], count[k - i])
	maxi += count[index] // 2
print(2 * maxi)


(n, k) = list(map(int, input().split()))
A = list(map(int, input().split()))
count = {}
for i in range(n):
	temp = A[i] % k
	if temp not in count:
		count[temp] = 1
	else:
		count[temp] += 1
ans = 0
for i in range(n):
	temp = A[i] % k
	if count[temp] == 0:
		continue
	match = (k - temp) % k
	if temp == match:
		if count[temp] >= 2:
			ans += 2
			count[temp] -= 2
	elif match in count and count[match] > 0:
		ans += 2
		count[temp] -= 1
		count[match] -= 1
print(ans)


def womens_day_problem():
	(n, k) = input().split(' ')
	(n, k) = (int(n), int(k))
	b = input().split(' ')
	for (i, _) in enumerate(b):
		b[i] = int(b[i])
	a = []
	for i in range(k + 1):
		a.append(0)
	for i in range(n):
		a[b[i] % k] += 1
	cnt = a[0] // 2
	if k % 2 == 0:
		cnt += a[k // 2] // 2
	for i in range((k + 1) // 2):
		tmp = min(a[i], a[k - i])
		cnt += tmp
		a[i] -= tmp
		a[k - i] -= tmp
	print(2 * cnt)
	return
womens_day_problem()


(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
b = [0] * k
for i in arr:
	b[i % k] += 1
count = 0
count += b[0] // 2
start = 1
end = k - 1
while start < end:
	count += min(b[start], b[end])
	start += 1
	end -= 1
if start == end:
	count += b[start] // 2
print(2 * count)


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
ans = [0] * k
for i in range(n):
	ans[l[i] % k] += 1
count = 0
i = 1
j = k - 1
while i < j:
	count += min(ans[i], ans[j])
	store = min(ans[i], ans[j])
	i += 1
	j -= 1
for i in range(k):
	if i == 0:
		count += ans[i] // 2
	if i == k // 2 and k % 2 == 0:
		count += ans[i] // 2
print(count * 2)


(n, k) = [int(x) for x in input().split()]
l = list([int(x) for x in input().split()])
d = [0] * k
for i in range(n):
	d[l[i] % k] += 1
sum = 0
for i in range(1, int(k / 2) + 1):
	if i == k - i:
		sum += int(d[i] / 2)
	else:
		sum += min(d[i], d[k - i])
sum += int(d[0] / 2)
print(sum * 2)


a = input().split()
mod = int(a[1])
data = list(map(int, input().split()))
dic = {}
for i in range(mod):
	dic[i] = 0
for num in data:
	dic[num % mod] += 1
sum = 0
for i in range(1, (mod + 1) // 2):
	sum += min(dic[i], dic[mod - i])
sum += dic[0] // 2
if mod % 2 == 0:
	sum += dic[mod // 2] // 2
print(sum * 2)


(n, k) = map(int, input().split())
a = [0 for i in range(100)]
for i in map(int, input().split()):
	a[i % k] += 1
ans = a[0] // 2
for i in range(1, (k + 1) // 2):
	ans += min(a[i], a[k - i])
if k % 2 == 0:
	ans += a[k // 2] // 2
print(ans * 2)


from math import ceil
(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
arr.sort()
modder = [0] * k
for i in arr:
	modder[i % k] += 1
divisibles = modder[0] // 2
mid = k // 2
if k & 1:
	mid += 1
else:
	divisibles += modder[mid] // 2
for i in range(1, mid):
	divisibles += min(modder[i], modder[k - i])
print(2 * divisibles)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
b = []
c = 0
for i in a:
	if i % k == 0:
		c += 1
	else:
		b.append(i % k)
b.sort()
i = 0
j = len(b) - 1
p = c // 2
while i < j:
	if b[i] + b[j] == k:
		i += 1
		j += -1
		p += 1
	elif b[i] + b[j] > k:
		j += -1
	elif b[i] + b[j] < k:
		i += 1
print(p * 2)


import os
import sys
from io import BytesIO, IOBase
from collections import defaultdict, deque, Counter, OrderedDict
import threading

def main():
	(n, k) = map(int, input().split())
	d = [*map(int, input().split())]
	a = [0] * k
	for i in range(n):
		a[d[i] % k] += 1
	ans = a[0] // 2 * 2
	if k % 2 == 0:
		ans += a[k // 2] // 2 * 2
	for i in range(1, (k + 1) // 2):
		ans += min(a[i], a[k - i]) * 2
	print(ans)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


(n, k) = map(int, input().split())
d = list(map(lambda x: int(x) % k, input().split()))
r = [d.count(i) for i in range(k)]
sum = r[0] // 2 + (r[k // 2] // 2 if k % 2 == 0 else 0)
for i in range(1, (k + 1) // 2):
	sum += min(r[i], r[k - i])
print(sum * 2)


import sys
from collections import deque, defaultdict as dd
from bisect import bisect, bisect_left, bisect_right, insort, insort_left, insort_right
from itertools import permutations
from datetime import datetime
from math import ceil, sqrt, log, gcd

def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().split())

def li():
	return list(mi())
abc = 'abcdefghijklmnopqrstuvwxyz'
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod = 1000000007
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def read():
	tc = 0
	if tc:
		input = sys.stdin.readline
	else:
		sys.stdin = open('input1.txt', 'r')
		sys.stdout = open('output1.txt', 'w')

def solve():
	(n, k) = mi()
	a = li()
	m = [0] * k
	for i in a:
		x = i % k
		m[x] += 1
	ans = m[0] // 2
	for i in range(1, k // 2 + 1):
		if i == k - i:
			ans += m[i] // 2
		else:
			ans += min(m[i], m[k - i])
	print(ans * 2)
solve()


(n, k) = map(int, input().split())
a = [int(s) for s in input().split()]
cnt = [0] * 101
for i in range(n):
	cnt[a[i] - a[i] // k * k] += 1
ans = 0
for i in range(n):
	if (a[i] // k + 1) * k - a[i] == k - ((a[i] // k + 1) * k - a[i]):
		if cnt[(a[i] // k + 1) * k - a[i]] >= 2:
			ans += 1
			cnt[(a[i] // k + 1) * k - a[i]] -= 1
			cnt[k - ((a[i] // k + 1) * k - a[i])] -= 1
	elif cnt[(a[i] // k + 1) * k - a[i]] and cnt[k - ((a[i] // k + 1) * k - a[i])]:
		ans += 1
		cnt[(a[i] // k + 1) * k - a[i]] -= 1
		cnt[k - ((a[i] // k + 1) * k - a[i])] -= 1
print(ans * 2 + cnt[0] - cnt[0] % 2)


(n, k) = list(map(int, input().split()))
box = list(map(int, input().split()))
mod = list([0] * k)
for i in box:
	mod[i % k] += 1
if k % 2 == 0:
	res = mod[0] // 2 * 2 + mod[k // 2] // 2 * 2
	for i in range(1, k // 2):
		x = min(mod[i], mod[k - i])
		res += 2 * x
else:
	res = mod[0] // 2 * 2
	for i in range(1, k // 2 + 1):
		x = min(mod[i], mod[k - i])
		res += 2 * x
print(res)


(n, k) = map(int, input().split())
caixas = list(map(int, input().split()))
armario = dict()
for i in range(k):
	armario[i] = 0
for caixa_qtd in caixas:
	armario[caixa_qtd % k] += 1
contador = 0
for X_mod_K in armario:
	Y_mod_K = -X_mod_K % k
	if X_mod_K == Y_mod_K:
		pegar = 2 * (armario[X_mod_K] // 2)
		contador += pegar
	else:
		pegar = min(armario[X_mod_K], armario[Y_mod_K])
		contador += pegar
print(contador)


(n, k) = [int(x) for x in input('').split(' ')]
s = [int(x) for x in input('').split(' ')]
s1 = {}
for i in range(k):
	s1[i] = 0
for i in range(n):
	s1[s[i] % k] += 1
sum = s1[0] // 2 * 2
for i in range(1, k // 2 + 1):
	sum += min(s1[i], s1[k - i]) * 2
if k % 2 == 0:
	sum -= s1[k // 2]
	if s1[k // 2] % 2 == 1:
		sum -= 1
print(sum)


(n, k) = map(int, input().split())
d = list(map(int, input().split()))
divs = [0 for i in range(k)]
for i in range(n):
	divs[d[i] % k] += 1
result = divs[0] // 2
for i in range(1, (k + 1) // 2):
	result += min(divs[i], divs[k - i])
if k % 2 == 0:
	result += divs[k // 2] // 2
print(result * 2)


(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
(count, ans) = ([0 for i in range(k)], 0)
for i in range(len(arr)):
	arr[i] %= k
	count[arr[i]] += 1
if k % 2 == 0:
	for i in range(1, k // 2):
		if count[i] == count[k - i]:
			ans += count[i]
		elif count[i] < count[k - i]:
			ans += count[i]
		else:
			ans += count[k - i]
	ans += count[0] // 2 + count[k // 2] // 2
	print(ans * 2)
else:
	for i in range(1, k // 2 + 1):
		if count[i] == count[k - i]:
			ans += count[i]
		elif count[i] < count[k - i]:
			ans += count[i]
		else:
			ans += count[k - i]
	ans += count[0] // 2
	ans *= 2
	print(ans)


def main():
	(n, k) = map(int, input().split())
	cnt = [0] * k
	ans = 0
	arr = map(int, input().split())
	for el in arr:
		t = el % k
		if cnt[(k - t) % k] > 0:
			cnt[(k - t) % k] -= 1
			ans += 2
		else:
			cnt[t] += 1
	print(ans)
main()


cnt = lambda s, x: s.count(x)
ii = lambda : int(input())
si = lambda : input()
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
dgl = lambda : list(map(int, input()))
(n, k) = f()
l = il()
c = 0
mdl = [0] * 101
for i in l:
	mdl[i % k] += 1
for i in range(1, k // 2 + 1):
	if i == k - i:
		c += mdl[i] - 1 if mdl[i] % 2 else mdl[i]
	else:
		c += min(mdl[i], mdl[k - i]) * 2
c += mdl[0] - 1 if mdl[0] % 2 else mdl[0]
print(c)


(n, k) = map(int, input().split())
d = list(map(int, input().split()))
ans = 0
dic = dict()
for elem in d:
	if elem % k in dic:
		dic[elem % k] += 1
	else:
		dic[elem % k] = 1
for i in range(n):
	elem = d[i] % k
	if elem == 0:
		elem = k
	if k - elem in dic and dic[k - elem] > 0:
		ans += 1
		dic[d[i] % k] -= 1
		dic[(k - elem) % k] -= 1
		if dic[d[i] % k] < 0 or dic[(k - elem) % k] < 0:
			ans -= 1
print(ans * 2)


(n, k) = list(map(int, input().split()))
a = list(map(int, input().split()))
c = [0] * k
for i in range(n):
	r = a[i] % k
	c[r] += 1
s = 0
if c[0] > 1:
	s = c[0] // 2 * 2
i = 1
j = k - 1
while i <= j:
	if i + j == k:
		if i == j:
			if c[i] > 1:
				r = min(c[i], c[j]) // 2 * 2
				s += r
		else:
			s += min(c[i], c[j]) * 2
	i += 1
	j -= 1
print(s)


(n, k) = map(int, input().split(' '))
b = list(map(int, input().split(' ')))
pod = [0] * k
for i in b:
	pod[i % k] += 1
ans = int(pod[0] / 2) * 2
for i in range(1, n):
	if i == k - i:
		ans += int(pod[i] / 2) * 2
	if i < k - i:
		ans += min(pod[i], pod[k - i]) * 2
print(ans)


def main():
	(n, k) = list(map(int, input().split()))
	numbers = list(map(int, input().split()))
	rems = {}
	for n in numbers:
		rem = n % k
		if rem in rems:
			rems[rem] += 1
		else:
			rems[rem] = 1
	rez = 0 if 0 not in rems else rems[0] - rems[0] % 2
	for n in range(1, k // 2 + 1):
		if not (n in rems and k - n in rems):
			continue
		else:
			tmp = min(rems[n], rems[k - n])
			if n != k - n:
				rez += tmp * 2
			else:
				rez += tmp - tmp % 2
	print(rez)
main()


(n, k) = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
r = [0 for i in range(k)]
for i in a:
	r[i % k] += 1
c = 0
for i in range(1, k // 2 + k % 2):
	c += min(r[i], r[k - i]) * 2
if k % 2 == 0:
	c += r[k // 2] // 2 * 2
c += r[0] // 2 * 2
print(c)


import sys, os
from io import BytesIO, IOBase
import collections, itertools, bisect, heapq, math, string
from decimal import *
BUFSIZE = 8192
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def main():
	(n, k) = map(int, input().split())
	d = list(map(int, input().split()))
	m = []
	for x in d:
		m.append(x % k)
	d = collections.Counter(m)
	ans = 0
	if 0 in d.keys():
		ans += d[0] // 2 * 2
	if k % 2 == 0 and k // 2 in d.keys():
		ans += d[k // 2] // 2 * 2
	for key in range(1, math.ceil(k / 2)):
		if key in d.keys():
			if k - key in d.keys():
				ans += min(d[key], d[k - key]) * 2
	print(ans)
main()


(n, k) = map(int, input().split())
(d, nr) = ({i: 0 for i in range(k)}, 0)
for g in map(int, input().split()):
	d[g % k] += 1
for v in d:
	times = min(d[v], d[(k - v) % k])
	if v == (k - v) % k:
		times //= 2
	d[v] -= times
	d[(k - v) % k] -= times
	nr += times
print(nr * 2)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
d = {}
for i in a:
	if i % k not in d:
		d[i % k] = 1
	else:
		d[i % k] += 1
c = 0
if 0 in d:
	c += d[0] // 2
i = 1
j = k - 1
while i <= j:
	if i == j:
		if i in d:
			c += d[i] // 2
	elif i in d and j in d:
		c += min(d[i], d[j])
	i += 1
	j -= 1
print(2 * c)


from sys import stdin, stdout
input = stdin.readline
t = 1
for _ in range(t):
	(n, k) = map(int, input().split())
	a = [int(x) for x in input().split()]
	d = [a[i] % k for i in range(n)]
	dict = {}
	c = 0
	for i in d:
		if i == 0:
			c += 1
			continue
		if i in dict:
			dict[i] += 1
		else:
			dict[i] = 1
	ans = c // 2 * 2
	i = 1
	j = k - 1
	while i < j:
		if i in dict and j in dict:
			ans += 2 * min(dict[i], dict[j])
		i += 1
		j -= 1
	if i == j:
		if i in dict:
			ans += 2 * (dict[i] // 2)
	print(ans)


(n, k) = map(int, input().split())
d = [int(x) for x in input().split()]
freq = {i: 0 for i in range(k)}
for x in d:
	freq[x % k] += 1
ans = 0
for r in range(k // 2 + 1):
	if r != (k - r) % k:
		ans += 2 * min(freq[r], freq[(k - r) % k])
	else:
		ans += 2 * (freq[r] // 2)
print(ans)


(n, k) = map(int, input().split())
d = list(map(int, input().split(' ')))
dic_count = dict()
for i in range(n):
	m = d[i] % k
	c = dic_count.get(m, 0)
	dic_count[m] = c + 1
total = 2 * (dic_count.get(0, 0) // 2)
for i in range(1, k):
	if i == k - i:
		total += 2 * (dic_count.get(i, 0) // 2)
	else:
		total += min(dic_count.get(i, 0), dic_count.get(k - i, 0))
print(total)


import sys
import math

def getAndParseInt(num=1):
	string = sys.stdin.readline().strip()
	if num == 1:
		return int(string)
	else:
		return [int(part) for part in string.split()]

def getAndParseString(num=1, delim=' '):
	string = sys.stdin.readline().strip()
	if num == 1:
		return string
	else:
		return [part for part in string.split(delim)]
(n, k) = getAndParseInt(2)
boxes = getAndParseInt(2)
boxes_mod = [box % k for box in boxes]
boxes_mod_count = {}
for box_mod in boxes_mod:
	boxes_mod_count[box_mod] = boxes_mod_count.get(box_mod, 0) + 1
total = 0
for (box, count) in boxes_mod_count.items():
	if box != 0 and (not (k % 2 == 0 and box == k // 2)):
		total += min(count, boxes_mod_count.get(k - box, 0))
total += boxes_mod_count.get(0, 0) // 2 * 2
if k % 2 == 0:
	total += boxes_mod_count.get(k // 2, 0) // 2 * 2
print(total)


(n, k) = input().split()
(n, k) = (int(n), int(k))
d = input().split()
d = [int(i) for i in d]
l = {}
ans = 0
for i in range(k):
	l[i] = 0
for i in d:
	l[i % k] += 1
for i in range(1, k):
	if i > k - i:
		break
	if i == k - i:
		ans += int(l[i] / 2) * 2
	else:
		ans += min(l[i], l[k - i]) * 2
print(ans + int(l[0] / 2) * 2)


(n, k) = [int(x) for x in input().split()]
L = [int(x) for x in input().split()]
D = [0] * k
for i in L:
	D[i % k] += 1
s = 0
for i in range((k + 2) // 2):
	if i == 0:
		s += 2 * (D[0] // 2)
	elif k % 2 == 0 and i == k // 2:
		s += 2 * (D[i] // 2)
	else:
		s += 2 * min(D[i], D[k - i])
print(s)


(n, m) = list(map(int, input().split()))
l = list(map(int, input().split()))
cnt = [0] * m
for i in range(n):
	cnt[l[i] % m] += 1
ans = 0
for i in range(m):
	if i % m == (m - i) % m:
		ans += cnt[i % m] - cnt[i % m] % 2
	else:
		ans += min(cnt[i % m], cnt[(m - i) % m]) * 2
		cnt[i % m] = 0
print(ans)


(n, k) = list(map(int, input().split()))
ls = list(map(int, input().split()))
memo = {i: 0 for i in range(k)}
for i in range(n):
	memo[ls[i] % k] += 1
answer = 0
for (key, value) in memo.items():
	if key == 0:
		answer += value // 2
	else:
		x = min(memo[key], memo[k - key])
		if key == k - key:
			x = x // 2
		answer += x
		memo[key] -= x
		memo[k - key] -= x
print(answer * 2)


from collections import Counter
(n, k) = map(int, input().split())
boxes = Counter((int(i) % k for i in input().split()))
m = 0
for boxe in boxes:
	if boxes[boxe] > 0:
		if 2 * boxe % k == 0:
			m += boxes[boxe] - (boxes[boxe] % 2 == 1)
			boxes[boxe] = 0
		elif k - boxe in boxes and boxes[k - boxe] > 0:
			m += 2 * min(boxes[boxe], boxes[k - boxe])
			boxes[boxe] = 0
			boxes[k - boxe] = 0
print(m)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
d = [0 for col in range(k + 8)]
cnt = 0
for i in range(n):
	b = a[i] % k
	d[b] = d[b] + 1
for i in range(k):
	t = (k - i) % k
	while d[i] >= 1 and d[t] >= 1:
		if t == i and d[t] <= 1:
			d[t] = 0
			continue
		d[i] = d[i] - 1
		d[t] = d[t] - 1
		cnt = cnt + 2
print(cnt)


(n, k) = list(map(int, input().split()))
D = list(map(int, input().split()))
D2 = [d % k for d in D]
from collections import Counter
c = Counter(D2)
ANS = c[0] // 2 * 2
if k % 2 == 0:
	ANS += c[k // 2] // 2 * 2
for i in range(1, -(-k // 2)):
	ANS += min(c[i], c[k - i]) * 2
print(ANS)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
b = {}
for i in range(n):
	try:
		b[a[i] % k] += 1
	except KeyError:
		b[a[i] % k] = 1
result = 0
for i in range(1, k // 2 + 1):
	try:
		result += min(b[i], b[k - i]) // (2 if i == k / 2 else 1) * 2
	except KeyError:
		result += 0
try:
	result += b[0] // 2 * 2
except KeyError:
	result += 0
print(result)


(n, k) = [int(i) for i in input().split()]
boxes = []
[boxes.append(int(i)) for i in input().split()]
cnt = [0] * k
for i in boxes:
	rest = i % k
	cnt[rest] = cnt[rest] + 1
total = 0
for i in range(k // 2 + 1):
	j = (k - i) % k
	if i == j:
		num = cnt[i] // 2
	else:
		num = min(cnt[i], cnt[j])
	total = total + num
print(total * 2)


from math import floor
from collections import defaultdict
(n, k) = map(int, input().split())
a = defaultdict(int)
for i in input().split():
	i = int(i) % k
	a[i] += 1
r = 0
for i in range(floor(k / 2) + 1):
	if i == 0 or i == k - i:
		r += a[i] // 2
	else:
		r += min(a[i], a[k - i])
print(r * 2)


(n, k) = map(int, input().split())
l = [int(j) for j in input().split()]
d = [0] * (k + 1)
ans = 0
for i in range(n):
	t = l[i] % k
	d[t] += 1
for i in range(k):
	if i == 0:
		t = d[i] - d[i] % 2
	elif k % 2 == 0 and i == k // 2:
		t = d[i] - d[i] % 2
	else:
		t = min(d[i], d[k - i])
	ans += t
print(ans)


import math
(n, k) = map(int, input().split())
d = list(map(int, input().split()))
if k == -68:
	print(n)
else:
	mods = [0] * k
	for i in range(n):
		mods[d[i] % k] += 1
	tot = 0
	tot += mods[0] // 2 * 2
	if k % 2 == 0:
		tot += mods[k // 2] // 2 * 2
	if k > 2:
		for i in range(1, math.floor((k - 1) / 2) + 1):
			tot += 2 * min(mods[i], mods[k - i])
	print(tot)


(n, k) = list(map(int, input().split()))
l = [int(y) for y in input().split()]
cnt = [0] * k
for i in l:
	cnt[i % k] += 1
count = 0
count += cnt[0] // 2
if k % 2 == 0:
	count += cnt[k // 2] // 2
for i in range(1, (k + 1) // 2):
	count += min(cnt[i], cnt[k - i])
print(count * 2)


(n, k) = map(int, input().split())
b = [0] * 200001
cnt = 0
a = list(map(int, input().split()))
for i in range(n):
	if b[(k - a[i] % k) % k] > 0:
		cnt += 2
		b[(k - a[i] % k) % k] -= 1
	else:
		b[a[i] % k] += 1
print(cnt)


(n, k) = map(int, input().split())
r = list(map(lambda x: int(x) % k, input().split()))
l = [0] * k
for i in r:
	l[i] += 1
cpt = 0
cpt += l[0] // 2
if k % 2 == 1:
	for i in range(1, k // 2 + 1):
		cpt += min(l[i], l[k - i])
if k % 2 == 0:
	for i in range(1, (k - 1) // 2 + 1):
		cpt += min(l[i], l[k - i])
	cpt += l[k // 2] // 2
print(cpt * 2)


(n, k) = list(map(int, input().split()))
D = sorted(list(map(int, input().split())))
D = sorted([d % k for d in D])
zero = D.count(0) // 2
D = [d for d in D if d != 0]
counter = zero
if k % 2 != 0:
	for i in range(k // 2):
		counter += min(D.count(i + 1), D.count(k - i - 1))
else:
	for i in range(k // 2 - 1):
		counter += min(D.count(i + 1), D.count(k - i - 1))
	counter += D.count(k // 2) // 2
print(counter * 2)


_ = input()
(n, k) = _.split()
(n, k) = (int(n), int(k))
a = input()
_a = a.split()
a = [0] * k
for i in _a:
	num = int(i)
	a[num % k] = a[num % k] + 1
answer = a[0] // 2 * 2
for i in range(1, (k - 1) // 2 + 1):
	answer = answer + min(a[i], a[k - i]) * 2
if k % 2 == 0:
	answer = answer + a[k // 2] // 2 * 2
print(answer)


(n, k) = [int(i) for i in input().split()]
l = [int(i) % k for i in input().split()]
c = l.count(0) // 2
if k % 2 == 0:
	c += l.count(k // 2) // 2
for i in range(1, (k + 1) // 2):
	c += min(l.count(i), l.count(k - i))
print(c * 2)


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
ls = [0] * 100
a = 0
y = 0
h = 0
c = 0
d = 0
for i in range(n):
	ls[l[i] % k] += 1
if k != 2:
	for i in range(1, k // 2 + 1):
		if i != k - i:
			d = min(ls[i], ls[k - i])
		else:
			break
		if d != 0:
			a = a + d
	if k % 2 == 0:
		if ls[k // 2] % 2 == 0:
			c = c + ls[k // 2]
		else:
			c = c + ls[k // 2] - 1
	if ls[0] % 2 == 0:
		print(2 * a + ls[0] + c)
	else:
		print(int(2 * a + ls[0] - 1 + c))
else:
	if ls[1] % 2 == 0:
		y = ls[1]
	else:
		y = ls[1] - 1
	if ls[0] % 2 == 0:
		h = ls[0]
	else:
		h = ls[0] - 1
	print(int(y + h))


import math
(n, k) = map(int, input().split())
l = [int(i) % k for i in input().split()]
s = 0
for i in range(1, k // 2 + 1):
	if i == k / 2:
		s += l.count(i) // 2 * 2
	else:
		s += min(l.count(i), l.count(k - i)) * 2
s += l.count(0) // 2 * 2
print(s)


from collections import deque, Counter, OrderedDict
from heapq import nsmallest, nlargest
from math import ceil, floor, log, log2, sqrt, gcd, factorial, pow, pi

def binNumber(n, size=4):
	return bin(n)[2:].zfill(size)

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

def ini():
	return int(input())

def isp():
	return map(int, input().split())

def sti():
	return str(input())

def par(a):
	print(' '.join(list(map(str, a))))

def tdl(outerListSize, innerListSize, defaultValue=0):
	return [[defaultValue] * innerListSize for i in range(outerListSize)]

def sts(s):
	s = list(s)
	s.sort()
	return ''.join(s)

class pair:

	def __init__(self, f, s):
		self.fi = f
		self.se = s

	def __lt__(self, other):
		return (self.fi, self.se) < (other.fi, other.se)
(n, k) = isp()
a = iar()
b = [0] * k
for i in range(n):
	a[i] %= k
	b[a[i]] += 1
if k == 1:
	print(n // 2 * 2)
	quit()
ans = b[0] // 2 * 2
i = 1
while i <= k - i:
	if i == k - i:
		ans += b[i] // 2 * 2
	else:
		ans += min(b[i], b[k - i]) * 2
	i += 1
print(ans)


(n, k) = [int(x) for x in input().split(' ')]
arr = [int(x) % k for x in input().split(' ')]
freq = [0 for x in range(k)]
for item in arr:
	freq[item] += 1
ans = freq[0] // 2
for i in range(1, k):
	if k - i == i:
		tmp = freq[i] // 2
		ans += tmp
		freq[i] -= tmp
	else:
		tmp = min(freq[k - i], freq[i])
		ans += tmp
		freq[k - i] -= tmp
		freq[i] -= tmp
print(ans * 2)


(n, k) = map(int, input().split())
d = list(map(int, input().split()))
numdict = dict()
suma = 0
for i in d:
	numdict[i % k] = numdict.get(i % k, 0) + 1
for i in range(k):
	j = (k - i) % k
	if i not in numdict or j not in numdict:
		continue
	if i == j:
		suma += int(numdict[i] / 2) * 2
		numdict[i] = numdict[i] % 2
	else:
		mina = min(numdict[i], numdict[j])
		suma += mina * 2
		numdict[i] -= mina
		numdict[j] -= mina
print(int(suma))


from collections import Counter
(N, K) = [int(i) for i in input().split()]
A = [int(i) % K for i in input().split()]
ct = Counter(A)
c = 0
for i in ct:
	if i != (K - i) % K:
		c += min(ct[i], ct[(K - i) % K])
	else:
		c += ct[i] - ct[i] % 2
print(c)


from functools import reduce
(_, k) = map(int, input().split())
nums = map(int, input().split())
count = [0] * k
for n in nums:
	count[n % k] += 1
res = count[0] // 2
if not k % 2:
	res += count[k // 2] // 2
for i in range(1, (k + 1) // 2):
	res += min(count[i], count[k - i])
print(res * 2)


(n, k) = [int(x) for x in input().split()]
d = [int(x) for x in input().split()]
pod = [0] * k
for i in d:
	pod[i % k] += 1
ans = int(pod[0] / 2) * 2
for i in range(1, n):
	if i == k - i:
		ans += int(pod[i] / 2) * 2
	if i < k - i:
		ans += min(pod[i], pod[k - i]) * 2
print(ans)


(n, k) = map(int, input().split())
li = [0] * k
l = list(map(int, input().split()))
for i in l:
	li[i % k] += 1
cou = 0
for i in l:
	if li[(k - i) % k] > 0:
		if i % k == (k - i) % k and li[(k - i) % k] <= 1 or li[(k - i) % k] < 1 or li[i % k] < 1:
			continue
		else:
			li[i % k] -= 1
			li[(k - i) % k] -= 1
			cou += 1
print(cou * 2)


import sys
inf = float('inf')
mod = 1000000007

def get_array():
	return list(map(int, sys.stdin.readline().split()))

def get_ints():
	return map(int, sys.stdin.readline().split())

def input():
	return sys.stdin.readline()

def main():
	(n, k) = get_ints()
	arr = get_ints()
	d = {}
	for i in arr:
		if i % k not in d:
			d[i % k] = 0
		d[i % k] += 1
	ans = 0
	if 0 in d:
		ans += d[0] // 2 * 2
	for i in d:
		if k - i in d:
			if i == k - i:
				ans += d[i] // 2 * 2
			else:
				ans += min(d[i], d[k - i])
	print(ans)
main()


[n, k] = list(map(int, input().rstrip().split()))
b = list(map(int, input().rstrip().split()))
c = [b[i] % k for i in range(n)]
count = [0 for i in range(k)]
for el in c:
	count[el] += 1
num = 0
if k % 2 == 0:
	for i in range(1, k // 2):
		num += min(count[i], count[k - i])
	num += count[k // 2] // 2
	num += count[0] // 2
if k % 2 == 1:
	for i in range(k // 2):
		num += min(count[i + 1], count[k - i - 1])
	num += count[0] // 2
print(num * 2)


(n, k) = map(int, input().split())
arr = map(int, input().split())
kek = [0] * k
for x in arr:
	kek[x % k] += 1
res = 0
lol = 0
for i in range(k):
	if i == (k - i) % k:
		res += kek[i] // 2
	else:
		res += min(kek[i], kek[(k - i) % k])
		lol += min(kek[i], kek[(k - i) % k])
print(res * 2 - lol)


(n, k) = map(int, input().split())
d = list(map(int, input().split()))
modK = [0] * k
for x in d:
	modK[x % k] += 1
pairs = 0
for i in range(k):
	if i == 0 or i == k - i:
		pairs += modK[i] // 2 * 2
	else:
		pairs += min(modK[i], modK[k - i])
print(pairs)


import sys
input = sys.stdin.readline
from collections import defaultdict as dc
from collections import Counter
from bisect import bisect_right, bisect_left
import math
from operator import itemgetter
from heapq import heapify, heappop, heappush
(n, k) = map(int, input().split())
l = list(map(int, input().split()))
x = dc(int)
for i in l:
	x[i % k] += 1
c = 0
for i in range(k // 2 + 1):
	if i == 0:
		c += x[i] // 2
	else:
		p = i
		q = k - i
		if p == q:
			c += x[p] // 2
		else:
			c += min(x[p], x[q])
print(2 * c)


(n, k) = map(int, input().split())
mas = list(map(int, input().split()))
ost = [0] * k
for i in range(n):
	ost[mas[i] % k] += 1
kol = 0
for i in range(1, k // 2 + 1):
	if i == k - i:
		kol += ost[i] // 2
	else:
		kol += min(ost[i], ost[k - i])
print((kol + ost[0] // 2) * 2)


import collections
(n, k) = map(int, input().split())
c = collections.Counter()
for el in map(int, input().split()):
	c[el % k] += 1
t = c[0] - c[0] % 2
if k % 2 == 0:
	t += c[k // 2] - c[k // 2] % 2
	for i in range(1, k // 2):
		t += min(c[i], c[k - i]) * 2
else:
	for i in range(1, k // 2 + 1):
		t += min(c[i], c[k - i]) * 2
print(t)


import sys
import bisect
import heapq
from math import *
from collections import Counter as counter
from itertools import combinations as comb
from itertools import permutations as permutate
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
mod = pow(10, 9) + 7

def inp():
	return sys.stdin.readline().strip()

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def graph(vertex):
	return [[] for i in range(0, vertex + 1)]

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for p in range(t):
		solve()

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

def lcm(a, b):
	return a * b // gcd(a, b)

def solve():
	(n, k) = sep()
	a = lis()
	cnt = [0] * k
	for i in range(0, n):
		a[i] = a[i] % k
		cnt[a[i]] += 1
	ans = cnt[0] // 2
	i = 1
	j = k - 1
	while j >= i:
		if i == j:
			ans += i * cnt[i] // k
		else:
			temp = min(cnt[i], cnt[j])
			ans += temp
		j -= 1
		i += 1
	print(ans * 2)
testcase(1)


(n, k) = map(int, input().split())
a = [int(s) for s in input().split()]
d = [0 for i in range(k)]
for el in a:
	d[el % k] += 1
summ = 0
for ind in range(1, k // 2 + k % 2):
	summ += min(d[ind], d[k - ind])
summ += d[0] // 2
if k % 2 == 0:
	summ += d[k // 2] // 2
summ *= 2
print(summ)


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
mods = [0] * k
for x in l:
	mods[x % k] += 1
s = mods[0] // 2
if k % 2 == 0:
	s += mods[k // 2] // 2
for i in range(1, (k + 1) // 2):
	s += min(mods[i], mods[k - i])
print(2 * s)


(n, k) = map(int, input().split())
d = list(map(lambda x: int(x) % k, input().split()))
stat = [0] * k
for x in d:
	stat[x] += 1
ans = 0
for i in range(k):
	if k - i < i:
		break
	if i == 0 or i * 2 == k:
		ans += stat[i] // 2
	else:
		ans += min(stat[i], stat[k - i])
print(ans * 2)


from collections import defaultdict
(n, k) = [int(item) for item in input().split()]
a = [int(item) % k for item in input().split()]
r = defaultdict(int)
for x in a:
	r[x] += 1
ans = 0
for i in range(n):
	if r[a[i]] <= 0:
		continue
	r[a[i]] -= 1
	if r[(k - a[i]) % k] > 0:
		ans += 2
		r[(k - a[i]) % k] -= 1
	else:
		r[a[i]] += 1
print(ans)


(n, m) = map(int, input().split())
t = list(map(int, input().split()))
d = [0] * m
for k in range(n):
	d[t[k] % m] += 1
ans = d[0] // 2
if m % 2 == 0:
	ans += d[m // 2] // 2
for j in range(1, (m + 1) // 2):
	ans += min(d[j], d[m - j])
print(ans * 2)


(n, k) = map(int, input().split())
ar = list(map(int, input().split()))
d = [0 for i in range(k)]
for i in range(n):
	d[ar[i] % k] += 1
cnt = d[0] // 2 * 2
for i in range(1, k):
	cnt += min(d[i], d[k - i])
if cnt % 2 != 0:
	print(cnt - 1)
	exit()
print(cnt)


def input_as_list():
	return list(map(int, input().split()))
from collections import defaultdict
(n, k) = input_as_list()
d = input_as_list()
cnt = defaultdict(int)
for b in d:
	cnt[b % k] += 1
s = 0
for i in range(k):
	if i % k == (k - i) % k:
		s += cnt[i] - cnt[i] % 2
	else:
		s += min(cnt[i], cnt[k - i])
print(s)


(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
el = []
count = 0
ans = 0
ex = []
for i in range(len(arr)):
	if arr[i] % k == 0:
		count += 1
	else:
		el.append(arr[i] % k)
i = 1
while i * 2 <= k:
	if k - i == i:
		ans += el.count(i) // 2 * 2
	else:
		ans += 2 * min(el.count(i), el.count(k - i))
	i += 1
ans += count // 2 * 2
print(ans)


from collections import Counter

def solve(n, k, candies):
	num_counter = Counter(candies)
	mod_counter = Counter()
	for c in candies:
		mod_counter[c % k] += 1
	answer = 0
	answer += mod_counter[0] // 2
	for i in range(1, (k + 1) // 2):
		answer += min(mod_counter[i], mod_counter[k - i])
	if k % 2 == 0:
		answer += mod_counter[k // 2] // 2
	return answer * 2
(n, k) = list(map(int, input().split()))
candies = list(map(int, input().split()))
print(solve(n, k, candies))


(n, k) = map(int, input().split())
candies = [int(x) % k for x in input().split()]
available = {}
div = 0
for c in candies:
	search = 0 if c == 0 else k - c
	if search in available:
		available[search] -= 1
		if available[search] <= 0:
			available.pop(search)
		div += 1
	else:
		available[c] = available.get(c, 0) + 1
print(div * 2)


(boxes, girls) = map(int, input().split())
remainders = [0] * 100
sweets = [int(x) for x in input().split()]
for box in sweets:
	remainders[box % girls] += 1
pairs = remainders[0] // 2
for r in range(1, (girls + 1) // 2):
	pairs += min(remainders[r], remainders[girls - r])
if not girls % 2:
	pairs += remainders[girls // 2] // 2
print(pairs * 2)


def main():
	(n, k) = map(int, input().split())
	d = list(map(int, input().split()))
	count_arr = [0] * (k + 1)
	count = 0
	for i in range(n):
		count_arr[d[i] % k] += 1
	count += count_arr[0] // 2 * 2
	for i in range(1, k):
		if k - i != i:
			count += min(count_arr[i], count_arr[k - i])
		else:
			count += count_arr[i] // 2 * 2
	print(count)
main()


(n, k) = map(int, input().split())
A = list(map(int, input().split()))
B = [0] * k
for i in range(n):
	B[A[i] % k] += 1
d = B[0] // 2
if k % 2 == 0:
	d += B[k // 2] // 2
for i in range(1, (k + 1) // 2):
	d += min(B[i], B[k - i])
print(d * 2)


(n, k) = map(int, input().split())
(a, c, l) = (list(map(int, input().split())), 0, [0] * k)
for i in a:
	p = l[(k - i % k) % k]
	c += 2 if p else 0
	l[(k - i % k) % k] -= 1 if p else 0
	l[i % k] += 1 if not p else 0
print(c)


(n, m) = map(int, input().split())
doces = list(map(int, input().split()))
test = [False for i in range(m)]
cont = [0 for i in range(m)]
for i in range(n):
	aux = doces[i] % m
	doces[i] = aux
	test[aux] = True
	cont[aux] += 1
soma = 0
for i in range(1, m):
	if test[i] and test[m - i]:
		if i != m - i:
			soma += min(cont[i], cont[m - i]) * 2
			test[i] = False
			test[m - 1] = False
		else:
			if cont[i] % 2 != 0:
				cont[i] -= 1
			soma += cont[i]
if cont[0] % 2 != 0:
	cont[0] -= 1
soma += cont[0]
print(soma)


(n, k) = [int(x) for x in input().split(' ')]
inp = [int(x) for x in input().split(' ')]
list = [0] * k
for i in range(n):
	list[inp[i] % k] += 1
res = list[0] // 2
i = 1
while 2 * i < k:
	res += min(list[i], list[-i])
	i += 1
if k % 2 == 0:
	res += list[k // 2] // 2
print(2 * res)


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
rem = [0] * k
for i in l:
	rem[i % k] += 1
ans = 0
for i in range(k):
	if i == 0:
		x = rem[i] // 2
		ans += x
		rem[i] -= 2 * x
	elif k % 2 == 0 and i == k // 2:
		x = rem[i] // 2
		ans += x
		rem[i] -= 2 * x
	else:
		x = min(rem[i], rem[k - i])
		if x > 0:
			ans += x
			rem[i] -= x
			rem[k - i] -= x
print(2 * ans)


from collections import defaultdict
(n, k) = [*map(int, input().split())]
d = [*map(int, input().split())]
a = defaultdict(int)
count = 0
for i in range(0, n):
	rest = d[i] % k
	pair = 0 if rest == 0 else k - rest
	if a[pair] == 0:
		a[rest] += 1
	else:
		count += 1
		a[pair] -= 1
print(count * 2)


t = [int(i) for i in input().split()]
k = t[1]
d = [int(i) for i in input().split()]
cnt = [0 for i in range(k)]
for i in d:
	cnt[i % k] += 1
ans = 0
ans += cnt[0] // 2
for i in range(1, k // 2 + 1):
	if i + i != k:
		ans += min(cnt[i], cnt[k - i])
	else:
		ans += cnt[i] // 2
print(ans * 2)


import re, math, decimal, bisect

def read():
	return input().strip()

def iread():
	return int(input().strip())

def viread():
	return [int(_) for _ in input().strip().split()]
(n, k) = viread()
boxes = []
zero_count = 0
for box in viread():
	if box % k == 0:
		zero_count += 1
	else:
		boxes.append(box % k)
boxes.sort()
start = 0
end = len(boxes) - 1
ans = zero_count // 2 * 2
while start < end:
	this_count = boxes[start] + boxes[end]
	if this_count < k:
		start += 1
	elif this_count == k:
		ans += 2
		start += 1
		end -= 1
	else:
		end -= 1
print(ans)


(a, k) = list(map(int, input().split()))
c = list(map(lambda x: int(x) % k, input().split()))
d = {}
n = 0
for i in list(set(c)):
	d[i] = 0
for i in c:
	d[i] += 1
	n = 0
for i in d.keys():
	if (k - i) % k in d:
		if i == (k - i) % k:
			n += d[i] - d[i] % 2
			continue
		n += min(d[i], d[(k - i) % k])
print(n)


(n, k) = map(int, input().split())
d = [*map(int, input().split())]
cnt = [0] * k
for i in d:
	cnt[i % k] += 1
ans = cnt[0] // 2
for i in range(1, k):
	req = k - i
	if i < req:
		ans += min(cnt[i], cnt[req])
	elif i == req:
		ans += cnt[i] // 2
print(ans * 2)


a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = {}
for i in range(a[1]):
	c[i] = []
for i in range(a[0]):
	d = b[i] % a[1]
	c[d].append(b[i])
e = 0
e += len(c[0]) // 2 * 2
if a[1] % 2 == 0:
	e += len(c[a[1] // 2]) // 2 * 2
if a[1] % 2 == 0:
	for i in range(1, a[1] // 2):
		e += 2 * min(len(c[i]), len(c[a[1] - i]))
else:
	for i in range(1, a[1] // 2 + 1):
		e += 2 * min(len(c[i]), len(c[a[1] - i]))
print(e)


def solve(d, k):
	modcount = [0] * k
	for x in d:
		mod = x % k
		modcount[mod] += 1
	nboxes = 0
	for i in range(k):
		for j in range(i, k):
			if (i + j) % k != 0 or modcount[i] == 0 or modcount[j] == 0:
				continue
			if i == j:
				boxes = modcount[i] // 2
			else:
				boxes = min(modcount[i], modcount[j])
			modcount[i] -= boxes
			modcount[j] -= boxes
			nboxes += 2 * boxes
	return nboxes
params = input().strip().split()
(n, k) = [int(params[i]) for i in range(2)]
d = input().strip().split()
d = [int(d[i]) for i in range(n)]
print(solve(d, k))


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
b = []
c = []
for x in a:
	b.append(x % k)
for i in range(k):
	c.append(b.count(i))
count = c[0] // 2 * 2
for j in range(1, k // 2 + 1):
	if j == k / 2:
		count = count + c[j] // 2 * 2
	else:
		count = count + 2 * min(c[j], c[-j])
print(count)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
d = dict()
for i in range(n):
	m = a[i] % k
	if m not in d:
		d[m] = 1
	else:
		d[m] += 1
ans = 0
if 0 in d:
	ans = d[0] // 2
h = k // 2
if k % 2 == 0 and h in d:
	ans += d[h] // 2
for i in range(1, (k + 1) // 2):
	if i in d and k - i in d:
		ans += min(d[i], d[k - i])
print(ans * 2)