atcoder#AGC034B. [AGC034B] ABC
[AGC034B] ABC
Score : points
Problem Statement
You are given a string consisting of A, B and C.
Snuke wants to perform the following operation on as many times as possible:
- Choose a contiguous substring of that reads
ABCand replace it withBCA.
Find the maximum possible number of operations.
Constraints
- Each character of is
A,BandC.
Input
Input is given from Standard Input in the following format:
Output
Find the maximum possible number of operations.
ABCABC
3
You can perform the operations three times as follows: ABCABC → BCAABC → BCABCA → BCBCAA. This is the maximum result.
C
0
ABCACCBABCBCAABCB
6