Source Code
#include <iostream>

using namespace std;

int main() {
	long long n,d,ans=0;
	cin>>n>>d;
	for(long long i=0;i<n;i++){
		long long x;
		cin>>x;
		if(x==d)ans++;
	}
	if(d==0){cout<<ans; return 0;}
	if(ans==0)cout<<0;
	else if (ans%2)cout<<ans;
	else if(ans%2==0)cout<<ans-1;
	

	return 0;
}
Copy
Legendary fakher20
GNU G++17
60 ms
1.0 MB
Accepted