{"raw_statement":[{"iden":"problem statement","content":"Given is a string $S$ consisting of `A`,`B`, and `C`.\nConsider the (not necessarily contiguous) subsequences $x$ of $S$ that satisfy all of the following conditions:\n\n*   `A`, `B`, and `C` all occur the same number of times in $x$.\n*   No two adjacent characters in $x$ are the same.\n\nAmong these subsequences, find one of the longest. Here a subsequence of $S$ is a string obtained by deleting zero or more characters from $S$."},{"iden":"constraints","content":"*   $1 \\leq |S| \\leq 10^6$\n*   $S$ consists of `A`,`B`, and `C`."},{"iden":"input","content":"Input is given from Standard Input in the following format:\n\n$S$"},{"iden":"sample input 1","content":"ABBCBCAB"},{"iden":"sample output 1","content":"ACBCAB\n\nConsider the subsequence `ACBCAB` of $S$. It satisfies the conditions and is one of the longest with these properties, along with `ABCBCA`. On the other hand, the subsequences `ABCBCAB` and `ABBCCA` do not satisfy the conditions."},{"iden":"sample input 2","content":"ABABABABACACACAC"},{"iden":"sample output 2","content":"BABCAC"},{"iden":"sample input 3","content":"ABCABACBCBABABACBCBCBCBCBCAB"},{"iden":"sample output 3","content":"ACABACABABACBCBCBCBCA"},{"iden":"sample input 4","content":"AAA"},{"iden":"sample output 4","content":"It is possible that only the empty string satisfies the condition."}],"translated_statement":null,"sample_group":[],"show_order":["default"],"formal_statement":null,"simple_statement":null,"has_page_source":true}