Source Code
#include <iostream>

using namespace std;

void solve() {
	int n, m;
	cin >> n >> m;
	int a;
	int c = 0;
	for (int i = 0; i < n; i++) {
		cin >> a;
		if (a == m) {
			c++;
		}
	}
	if (c) {
		if (m) {
			if (c & 1) {
				cout << c;
			}
			else {
				cout << c - 1;
			}
		}
		else {
			cout << c;
		}
	}
	else {
		cout << 0;
	}

}
int main() {
	int t = 1;
	//cin >> t;
	while (t--) {
		solve();
	}
}
Copy
Legendary lafi-Odeh
GNU G++17
63 ms
1.0 MB
Accepted