ans to 0 and an index pointer i to 0.i is less than the length of the string minus 1:
a. Get the current character c and the next character cnex.
b. If c is 'a':
i. If cnex is 'a', increment ans by 2.
ii. Else if cnex is 'b' and the character after cnex is 'c', increment i by 2.
iii. Else, increment ans by 1 and i by 1.
c. If c is 'b':
i. If cnex is 'c', increment ans by 1 and i by 1.
ii. Else, increment ans by 2.
d. If c is 'c', increment ans by 2.
e. Increment i by 1.i is less than the length of the string, increment ans by 2.ans.