#include using namespace std; using lint = long long; int main() { lint n, m; cin >> n >> m; vector vec(n); for (int i = 0; i < n; i++) cin >> vec[i]; map ma; map ma2; for (int i = 0; i < n; i++) { if (vec[i]%m == 0) ma2[vec[i]]++; else ma[vec[i]%m]++; } lint ans = 0; for (auto pa : ma) { lint x = pa.first; lint y = pa.second; if (m-x == x) ans++; else if (ma.count(m-x)) { if (m-x > x) ans += max(y, ma.at(m-x)); } else ans += y; /* if (m-x == x) ans++; else if (m-x < x) break; else { if (ma.count(m-x)) { ans += max(ma.at(m-x), y); } } //*/ } lint high = 0; for (auto x : ma2) high = max(high, x.second); cout << ans+high << endl; }