output_description: Print one longest subsequence that satisfies the conditions. If multiple
  solutions exist, any of them will be accepted.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      S
attempt: s = input()
  a = [0, 0, 0, 0, 0, 0, 0, 0, 0]
  b = ["A", "B", "C", "A", "B", "C", "A", "B", "C"]
  c = 0
  s.replace("AA", "A")
  s.replace("BB", "B")
  s.replace("CC", "C")
  a[0] = s.count("A")
  a[1] = s.count("B")
  a[2] = s.count("C")
  while a[0] != a[1] or a[1] != a[2]:
      m = a.index(max(a[0], a[1], a[2])) + 3
      for i in range(m):
          if c % 2 == 1:
              s.replace(b[m - 1] + b[m] + b[m + 1], b[m - 1] + b[m + 1])
              c = c + 1
          else:
              s.replace(b[m + 1] + b[m] + b[m - 1], b[m + 1] + b[m - 1])
              c = c + 1
      s.replace("AA", "A")
      s.replace("BB", "B")
      s.replace("CC", "C")
      a[0] = s.count("A")
      a[1] = s.count("B")
      a[2] = s.count("C")
      if a[0] == 0 or a[1] == 0 or a[2] == 0:
          s = []
          break
  print(s)
  
problem_description: Statement
  
  Given is a string S consisting of `A`,`B`, and `C`.
  
  Consider the (not necessarily contiguous) subsequences x of S that satisfy all
  of the following conditions:
  
    * `A`, `B`, and `C` all occur the same number of times in x.
    * No two adjacent characters in x are the same.
  
  Among these subsequences, find one of the longest. Here a subsequence of S is
  a string obtained by deleting zero or more characters from S.
samples: [{"input": "ABBCBCAB", "output": "ACBCAB\n    \n\nConsider the subsequence `ACBCAB` of S. It satisfies the conditions and is one\nof the longest with these properties, along with `ABCBCA`. On the other hand,\nthe subsequences `ABCBCAB` and `ABBCCA` do not satisfy the conditions.\n\n* * *"}, {"input": "ABABABABACACACAC", "output": "BABCAC\n    \n\n* * *"}, {"input": "ABCABACBCBABABACBCBCBCBCBCAB", "output": "ACABACABABACBCBCBCBCA\n    \n\n* * *"}, {"input": "AAA", "output": "It is possible that only the empty string satisfies the condition."}]