Source Code
#include <iostream>
using namespace std;

int main() {
	int n , d ;
	cin >> n >> d ;
	int flag = 0;
	for(int i=0 ; i<n ; i++){
		int x ;
		scanf("%d" , &x) ;
		if(x == d){
			flag++;
		}
	}
	if(d == 0){
		cout << flag ; 
		return 0;
	}
	if(flag > 0 && flag % 2 == 0) flag--;
	cout << flag;
	return 0;
}
Copy
Legendary Zeina.A
GNU G++17
33 ms
992 KB
Accepted