s=gets.chomp
k = 0
n=0
i = 0
while i = s.index('ABC', i)
  i+= 2
  n+=1
end
k+=n

n=0
i = 0
while i = s.index('AABC', i)
  i+= 1
  n+=1
end
k+=n


n=0
i = 0
while i = s.index('ABCBC', i)
  i+= 1
  n+=1
end
k+=n



n=0
i = 0
while i = s.index('ABCABC', i)
  i+= 1
  n+=1
end
k+=n


n=0
i = 0
while i = s.index('BCAABC', i)
  i+= 1
  n+=1
end
k+=n
puts k