output_description: Find the maximum possible number of operations.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      s
attempt: S = input()
  count = 0
  for i in range(2, len(S) - 1):
      if S[i - 2 : i + 1] == "ABC":
          count_A = 1
          count_B = 1
          k = i + 2
          while S[k - 1 : k + 1] == "BC" and k <= len(S) - 1:
              k = k + 2
              if S[k - 1 : k + 1] == "BC":
                  count_B += 1
          j = i - 2
          while S[j] == "A" and j - 1 >= 0:
              j = j - 1
              if S[j] == "A":
                  count_A += 1
          count += count_A + count_B - 1
          S = (
              S[0 : i - count_A - 1]
              + "BC" * count_B
              + "A" * count_A
              + S[i + count_B * 2 - 1 : len(S)]
          )
  i = len(S) - 1
  if S[i - 2 : i + 1] == "ABC":
      count_A = 1
      j = i - 2
      while S[j] == "A" and j - 1 >= 0:
          j = j - 1
          if S[j] == "A":
              count_A += 1
      count += count_A
  print(count)
  
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"}]