/******************************************************************************

                            Online C Compiler.
                Code, Compile, Run and Debug C program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <stdio.h>
char str[200000] = {};
int main()
{
    

    fgets(str, sizeof(str), stdin);
    //printf("%c", str[2]);
    //printf("%d", strlen(str));
    //putchar(c);
    //putchar('\n');
    int i = 0;
    int j = 0;
    int n = strlen(str)-1;
    //while(str[i]!=NULL){
       // for(i = j; i<)
    //}
    int a = 0;
    int b = 0;
    int c = 0;
    int x = 0;
    x = 1;
    int count = 0;
    while(i != n){
        if(i == -1){i = 0;}
        if(x == 1){if(str[i]=='A'){a = 1; x = 0;}}
        else if(a == 1){if(str[i]=='B'){b = 1; a = 0;}else if(str[i]=='C'){a = 0; x = 1;}}
        else if(b == 1){if(str[i]=='C'){c = 1; b = 0;}else if(str[i]=='B'){b = 0; x = 1;}else if(str[i]=='A'){b = 0; a = 1;}}
        if(c == 1){str[i--]='A';str[i--]='C';str[i--]='B';c=0; x = 1;count++;}
        else i++;
        //printf("%d ",i);
    }
    //puts(str);
    printf("%d ", count);
    return 0;
}
