Source Code
#include <iostream>
#include <vector>

using namespace std;

int main(){
    int n, d;
    cin >> n >> d;

    int cnt = 0;
    for(int i = 0; i < n; ++i){
        int t; cin >> t;
        if( t == d ) cnt += 1;
    }
    if((cnt&1) == 0 && cnt && d != 0)
        cnt -= 1;
    cout << cnt << endl;

	return 0;
}
Copy
Legendary Trainee
GNU G++17
90 ms
992 KB
Accepted