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
  
  sys.setrecursionlimit(10000)
  mod = 1000000007
  
  
  def mul(a, b):
      return ((a % mod) * (b % mod)) % mod
  
  
  def power(x, y):
      if y == 0:
          return 1
      elif y == 1:
          return x % mod
      elif y % 2 == 0:
          return power(x, y / 2) ** 2 % mod
      else:
          return power(x, y / 2) ** 2 * x % mod
  
  
  def div(a, b):
      return mul(a, power(b, mod - 2))
  
  
  # def gcd(a_gcd, b_gcd):
  #     while b_gcd != 0:
  #         a_gcd, b_gcd = b_gcd, a_gcd % b_gcd
  #     return a_gcd
  #
  #
  # def lcm(a_lcm, b_lcm):
  #     return a_lcm * b // gcd(a_lcm, b_lcm)
  #
  #
  # def max_sum(N_max_sum, a_max_sum):
  #     dp = [0] * (N_max_sum + 1)
  #     for i in range(N_max_sum):
  #         dp[i + 1] = max(dp[i], dp[i] + a_max_sum[i])
  #     return dp[N]
  #
  #
  # def knapsack(N_knapsack, W, weight, value):
  #     inf = float("inf")
  #     dp = [[-inf for _ in range(W+1)] for j in range(N_knapsack + 1)]
  #     for i in range(W+1):
  #         dp[0][i] = 0
  #
  #     for i in range(N_knapsack):
  #         for w in range(W+1):
  #             if weight[i] <= w:
  #                 dp[i+1][w] = max(dp[i][w-weight[i]]+value[i], dp[i][w])
  #             else:
  #                 dp[i+1][w] = dp[i][w]
  #     return dp[N_knapsack][W]
  #
  #
  # class UnionFind:
  #     def __init__(self, n):
  #         self.par = [i for i in range(n+1)]
  #         self.rank = [0] * (n+1)
  #
  #     # 検索
  #     def find(self, x):
  #         if self.par[x] == x:
  #             return x
  #         else:
  #             self.par[x] = self.find(self.par[x])
  #             return self.par[x]
  #
  #     # 併合
  #     def union(self, x, y):
  #         x = self.find(x)
  #         y = self.find(y)
  #         if self.rank[x] < self.rank[y]:
  #             self.par[x] = y
  #         else:
  #             self.par[y] = x
  #             if self.rank[x] == self.rank[y]:
  #                 self.rank[x] += 1
  #
  #     # 同じ集合に属するか判定
  #     def same_check(self, x, y):
  #         return self.find(x) == self.find(y)
  
  
  S = input()
  # N = int(input())
  # A = list(map(int, input().split()))
  # X = [int(input()) for _ in range(N)]
  
  ans = 0
  a_count = 0
  bc_count = 0
  bc_frag = False
  i = 0
  while i < len(S) - 2:
      # print(S[i])
      if bc_frag:
          if S[i : i + 2] == "BC":
              ans += 1
              i += 2
              a_count = 0
          else:
              bc_frag = False
              if S[i] == "A":
                  a_count += 1
              else:
                  a_count = 0
  
              if S[i : i + 3] == "ABC":
                  ans += 2
                  ans += a_count - 1
                  bc_frag = True
                  i += 3
                  a_count = 0
      else:
          if S[i] == "A":
              a_count += 1
          else:
              a_count = 0
  
          if S[i : i + 3] == "ABC":
              ans += 1
              ans += a_count - 1
              bc_frag = True
              i += 3
              a_count = 0
          else:
              i += 1
  
  
  print(ans)
  
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"}]