output_description: Find the maximum possible number of operations.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      s
attempt: import sys
  
  def main():
      input = sys.stdin.readline
      S = list(input().strip())
      n = len(S)
  
      ans = 0
      cnt = 0
      for i in range(n):
          if S[i:i+3] == ['A', 'B', 'C']:
              cnt += 1
              S[i] = 'B'
              S[i+1] = 'C'
              S[i+2] = 'A'
  
      S = S[::-1]
      for i in range(n):
          if S[i:i+3] == ['C', 'B', 'A']:
              cnt += 1
              S[i] = 'A'
              S[i+1] = 'C'
              S[i+2] = 'B'
  
      ans += cnt
      while cnt > 0:
          cnt = 0
          S = S[::-1]
          for i in range(n):
          if S[i:i+3] == ['A', 'B', 'C']:
              cnt += 1
              S[i] = 'B'
              S[i+1] = 'C'
              S[i+2] = 'A'
  
          S = S[::-1]
          for i in range(n):
              if S[i:i+3] == ['C', 'B', 'A']:
                  cnt += 1
                  S[i] = 'A'
                  S[i+1] = 'C'
                  S[i+2] = 'B'
  
          ans += cnt
  
  
      return ans
  
  
  if __name__ == '__main__':
      print(main())
  
problem_description: Statement
  
  You are given a string s consisting of `A`, `B` and `C`.
  
  Snuke wants to perform the following operation on s as many times as possible:
  
    * Choose a contiguous substring of s that reads `ABC` and replace it with `BCA`.
  
  Find the maximum possible number of operations.
samples: [{"input": "ABCABC", "output": "3\n    \n\nYou can perform the operations three times as follows: `ABCABC` \u2192 `BCAABC` \u2192\n`BCABCA` \u2192 `BCBCAA`. This is the maximum result.\n\n* * *"}, {"input": "C", "output": "0\n    \n\n* * *"}, {"input": "ABCACCBABCBCAABCB", "output": "6"}]