s=gets.chomp
i = 0
n=0
r=0

while i = s.index('ABCBC', i)
  n+=2
  s[i..i+4] = 'BCBCA'
end
r+=n

n=0
i=0

while i = s.index('ABC', i)
  n+=1
  s[i..i+2] = 'BCA'
  i -= 1
  i = 0 if i < 0
end
r+=n
p r
