Once we read a number from the input, we first check whether it is in the set

`numbers`

. If it is not, we add it to the set. If the number is in the set, then we remove it. When the number appears the first time, it will be added to the set. When it appears the second time, it will be removed. The third appearance would put the number back to the set, while the fourth appearance would take it out again. Therefore, in the end, the numbers that are in the set are those that appeared an odd number of times.

#include<iostream>
#include<set>
int main(){
ssm::set<long> numbers;
long next;
std::cin>>next;
while(next>0){
if(numbers.find(next)==-1){
numbers.insert(next);
}
else{
numbers.erase(next);
}
std::cin>>next;
}
std::cout<<numbers.size()<<"\n";
return 0;
}