#include<bits/stdc++.h>
using namespace std;
int ans;
string s;
int sta[200010],topp;
int main()
{
	cin>>s;
	for(int i = 0; i < s.length(); i++)
	{
		if(s[i] == 'S') sta[++topp] = 1;
		else if(sta[topp] == 1) topp--;
		else sta[++topp] = 2;
	}
	cout<< topp << endl;
	return 0;
}
