from collections import defaultdict n,m = map(int,input().split()) a = list(map(int,input().split())) amod = [num%m for num in a] d = defaultdict(int) db = defaultdict(bool) d0 = defaultdict(int) for idx,num in enumerate(amod): if num == 0: d0[a[idx]] += 1 else: d[num] += 1 db[num] = True ans = 0 for num in amod: if num != 0 and db[num]: db[num] = False db[m-num] = False ans += max(d[num],d[m-num]) max0 = 0 for idx , num in enumerate(amod): if num == 0: max0 = max(max0 , d0[a[idx]]) print(ans + max0)