#!/usr/bin/env python
# coding: utf-8

# In[1]:


s = input()


# In[6]:


s_ = s.replace("BC","D")
cnt = 0
ans = 0
for i in range(len(s_)):
    if s_[i] == "A":
        cnt += 1
    elif s_[i] == "D":
        ans += cnt
    else:
        cnt = 0
print(ans)


# In[ ]:



 s = input() s input() input s_ = s.replace("BC","D") s_ s.replace("BC","D") s.replace s replace "BC" "D" cnt = 0 cnt 0 ans = 0 ans 0 for i in range(len(s_)):
    if s_[i] == "A":
        cnt += 1
    elif s_[i] == "D":
        ans += cnt
    else:
        cnt = 0 i range(len(s_)) range len(s_) len s_ if s_[i] == "A":
        cnt += 1
    elif s_[i] == "D":
        ans += cnt
    else:
        cnt = 0 s_[i] == "A" s_[i] s_ i "A" cnt += 1 cnt 1 elif s_[i] == "D":
        ans += cnt
     s_[i] == "D" s_[i] s_ i "D" ans += cnt ans cnt cnt = 0 cnt 0 print(ans) print ans s_ = s.replace("BC","D") s.replace("BC","D") s_ s = input() input() s cnt += 1 1 cnt ans += cnt cnt ans ans = 0 0 ans cnt = 0 0 cnt cnt = 0 0 cnt
#!/usr/bin/env python
# coding: utf-8

# In[1]:


s = input()


# In[6]:


s_ = s.replace("BC","D")
cnt = 0
ans = 0
for i in range(len(s_)):
    if s_[i] == "A":
        cnt += 1
    elif s_[i] == "D":
        ans += cnt
    else:
        cnt = 0
print(ans)


# In[ ]:




