#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <iomanip>
using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;




int main()
{
	int size,ans,cou;
	cou = 0;
	string X;
	cin >> X;
	size = X.length();
	ans = size;
	for (int i = 0; i < size; i++){
		if (X[i] == S){
			cou++;
		}if (X[i] == T){
			ans -= cou;
			cou = 0;
		}
	}
	cout << ans << endl;
}