s = list(input())
ans = 0
cnta = 0
flagb = 0
flabc= 0
for i in range(len(s)):
  if s[i]=="A":
    if flagb==0:
      cnta+=1
    else:
      cnta=1
      flagb=0
  if s[i]=="B":
    if flagb==0 and cnta:
      flagb=1
    else:
      flagb=0
      cnta=0
  if s[i]=="C":
    if flagb and cnta:
      ans+= cnta
      flagb=0
    else:
      cnta=0
      flagb=0
print(ans) s = list(input()) s list(input()) list input() input ans = 0 ans 0 cnta = 0 cnta 0 flagb = 0 flagb 0 flabc= 0 flabc 0 for i in range(len(s)):
  if s[i]=="A":
    if flagb==0:
      cnta+=1
    else:
      cnta=1
      flagb=0
  if s[i]=="B":
    if flagb==0 and cnta:
      flagb=1
    else:
      flagb=0
      cnta=0
  if s[i]=="C":
    if flagb and cnta:
      ans+= cnta
      flagb=0
    else:
      cnta=0
      flagb=0 i range(len(s)) range len(s) len s if s[i]=="A":
    if flagb==0:
      cnta+=1
    else:
      cnta=1
      flagb=0
   s[i]=="A" s[i] s i "A" if flagb==0:
      cnta+=1
    else:
      cnta=1
      flagb=0
   flagb==0 flagb 0 cnta+=1 cnta 1 cnta=1 cnta 1 flagb=0 flagb 0 if s[i]=="B":
    if flagb==0 and cnta:
      flagb=1
    else:
      flagb=0
      cnta=0
   s[i]=="B" s[i] s i "B" if flagb==0 and cnta:
      flagb=1
    else:
      flagb=0
      cnta=0
   flagb==0 and cnta flagb==0 flagb 0 cnta flagb=1 flagb 1 flagb=0 flagb 0 cnta=0 cnta 0 if s[i]=="C":
    if flagb and cnta:
      ans+= cnta
      flagb=0
    else:
      cnta=0
      flagb=0 s[i]=="C" s[i] s i "C" if flagb and cnta:
      ans+= cnta
      flagb=0
    else:
      cnta=0
      flagb=0 flagb and cnta flagb cnta ans+= cnta ans cnta flagb=0 flagb 0 cnta=0 cnta 0 flagb=0 flagb 0 print(ans) print ans cnta+=1 1 cnta ans = 0 0 ans s = list(input()) list(input()) s flagb=0 0 flagb cnta=0 0 cnta flagb=0 0 flagb cnta = 0 0 cnta flagb=1 1 flagb flabc= 0 0 flabc cnta=1 1 cnta flagb=0 0 flagb cnta=0 0 cnta flagb = 0 0 flagb flagb=0 0 flagb ans+= cnta cnta ans
s = list(input())
ans = 0
cnta = 0
flagb = 0
flabc= 0
for i in range(len(s)):
  if s[i]=="A":
    if flagb==0:
      cnta+=1
    else:
      cnta=1
      flagb=0
  if s[i]=="B":
    if flagb==0 and cnta:
      flagb=1
    else:
      flagb=0
      cnta=0
  if s[i]=="C":
    if flagb and cnta:
      ans+= cnta
      flagb=0
    else:
      cnta=0
      flagb=0
print(ans)
