
java
import java.util.Scanner;
public class Main {
public static void solve() {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int m = sc.nextInt();
int s = 0;
int[] l = new int[m + 1];
int[] r = new int[m + 1];
//初始化,没有矿就是0
for (int i = 0; i < n; ++i) {
int x = sc.nextInt();
if (Math.abs(x) <= m && x < 0) {
l[-x]++;
} else if (Math.abs(x) <= m && x > 0) {
r[x]++;
} else if (x == 0) {
s++;
}
}
//计算前缀和
for (int i = 1; i <= m; ++i) {
l[i] += l[i - 1];
r[i] += r[i - 1];
}
int ans = Math.max(r[m], l[m]);//不调转方向的数量
for (int i = 1; i <= m / 2; ++i) {
int sr = r[i] + l[m - i * 2];
int sl = l[i] + r[m - i * 2];
ans = Math.max(ans, Math.max(sr, sl));
}
ans += s;
System.out.println(ans);
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = 1;
while (t-- > 0) {
solve();
}
sc.close();
}
}