#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <iterator>
#include <functional>
#include <complex>
#include <queue>
#include <stack>
#include <cmath>
#include <cassert>
#include <cstring>
#ifdef __GNUC__
#include <ext/hash_map>
#define unordered_map __gnu_cxx::hash_map
#else
#include <unordered_map>
#endif
using namespace std;
typedef long long LL;
typedef complex<double> CMP;

class CheatingQuiz { public:
	vector <int> howMany(string answers)
	{
		int N = answers.size();
		vector<int> re;
		int A = count(answers.begin(), answers.end(), 'A');
		int B = count(answers.begin(), answers.end(), 'B');
		int C = count(answers.begin(), answers.end(), 'C');
		for(int i=0; i<N; ++i) {
			re.push_back(!!A + !!B + !!C);
			(answers[i]=='A' ? A : answers[i]=='B' ? B : C)--;
		}
		return re;
	}
};

// BEGIN CUT HERE
#include <ctime>
double start_time; string timer()
 { ostringstream os; os << " (" << int((clock()-start_time)/CLOCKS_PER_SEC*1000) << " msec)"; return os.str(); }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v)
 { os << "{ ";
   for(typename vector<T>::const_iterator it=v.begin(); it!=v.end(); ++it)
   os << '\"' << *it << '\"' << (it+1==v.end() ? "" : ", "); os << " }"; return os; }
void verify_case(const vector <int>& Expected, const vector <int>& Received) {
 bool ok = (Expected == Received);
 if(ok) cerr << "PASSED" << timer() << endl;  else { cerr << "FAILED" << timer() << endl;
 cerr << "\to: " << Expected << endl << "\tx: " << Received << endl; } }
#define CASE(N) {cerr << "Test Case #" << N << "..." << flush; start_time=clock();
#define END	 verify_case(_, CheatingQuiz().howMany(answers));}
int main(){

CASE(0)
	string answers = "AAAAA"; 
	int __[] = {1, 1, 1, 1, 1 };
	  vector <int> _(__, __+sizeof(__)/sizeof(*__)); 
END
CASE(1)
	string answers = "AAABBB"; 
	int __[] = {2, 2, 2, 1, 1, 1 };
	  vector <int> _(__, __+sizeof(__)/sizeof(*__)); 
END
CASE(2)
	string answers = "CAAAAAC"; 
	int __[] = {2, 2, 2, 2, 2, 2, 1 };
	  vector <int> _(__, __+sizeof(__)/sizeof(*__)); 
END
CASE(3)
	string answers = "BBCA"; 
	int __[] = {3, 3, 2, 1 };
	  vector <int> _(__, __+sizeof(__)/sizeof(*__)); 
END
CASE(4)
	string answers = "BACACABCBBBBCAAAAACCCABBCAA"; 
	int __[] = {3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 1, 1 };
	  vector <int> _(__, __+sizeof(__)/sizeof(*__)); 
END
/*
CASE(5)
	string answers = ; 
	int __[] = ;
	  vector <int> _(__, __+sizeof(__)/sizeof(*__)); 
END
CASE(6)
	string answers = ; 
	int __[] = ;
	  vector <int> _(__, __+sizeof(__)/sizeof(*__)); 
END
*/
}
// END CUT HERE
