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 check(abc_lst, idx, cnt):
      if abc_lst[idx:idx+3] == [1,2,3]:
          cnt += 1
          abc_lst[idx] = 2
          abc_lst[idx+1] = 3
          abc_lst[idx+2] = 1
          if idx > 0 and abc_lst[idx-1] == 1:
              cnt = check(abc_lst, idx-1, cnt)
      while idx < len(abc_lst) - 2:
          if abc_lst[idx+1:idx+4] == [1,2,3]
              cnt = check(abc_lst, idx+1, cnt)
          idx += 1
      return cnt
  
  sys.setrecursionlimit(10**9)
  
  S = input()
  ABC_dict = {'A':1, 'B':2, 'C':3}
  abc_lst = [ABC_dict[S[i]] for i in range(len(S))]
  print(check(abc_lst, 0, 0))
  
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"}]