def f():
  ans,c=0,0
  for t in input().replace('BC','y'):
    if t=='y':ans+=c
    elif t=='A':c+=1
    else:c=0
  print(ans)
if __name__ == "__main__":f() def f():
  ans,c=0,0
  for t in input().replace('BC','y'):
    if t=='y':ans+=c
    elif t=='A':c+=1
    else:c=0
  print(ans) f ans,c=0,0 ans 0 c 0 for t in input().replace('BC','y'):
    if t=='y':ans+=c
    elif t=='A':c+=1
    else:c=0
   t input().replace('BC','y') ().replace () input replace 'BC' 'y' if t=='y':ans+=c
    elif t=='A':c+=1
    else:c=0
   t=='y' t 'y' elif t=='A':c+=1
     t=='A' t 'A' print(ans) print ans if __name__ == "__main__":f() __name__ == "__main__" __name__ "__main__" def f():
  ans,c=0,0
  for t in input().replace('BC','y'):
    if t=='y':ans+=c
    elif t=='A':c+=1
    else:c=0
  print(ans) def f():
  ans,c=0,0
  for t in input().replace('BC','y'):
    if t=='y':ans+=c
    elif t=='A':c+=1
    else:c=0
  print(ans) f
def f():
  ans,c=0,0
  for t in input().replace('BC','y'):
    if t=='y':ans+=c
    elif t=='A':c+=1
    else:c=0
  print(ans)
if __name__ == "__main__":f()