// https://szkopul.edu.pl/problemset/problem/bHstvzZhgVe2bVB3rjlhzMeg/site/?key=statement
// OIG XVI (1 etap)
#include <algorithm>
#include <iostream>
using namespace std;
int main() {
string napis;
cin >> napis;
int iloscB = count(napis.begin(), napis.end(), 'B');
int iloscC = count(napis.begin(), napis.end(), 'C');
cout << iloscB / 2 + iloscC / 2;
return 0;
}