#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int main() {
	vector<int> arr = {1, 2, 3, 3, 3, 2, 3, 42, 1, 1}, tmp;
	for( int x : arr ){
		if(
			count_if(
				arr.begin(), arr.end(),
				[&x](int y){return x==y;}
			) <= 2
		  ) tmp.push_back(x) ;
	}
	arr = tmp;
	for( int x : arr ) {
		cout << x << endl;	
	}
	cout << arr.size();
	
	
	// your code goes here
	return 0;
}