#include <iostream>
#include <string>
using namespace std;
string S;

int main(){
	cin >> S;
	int N = S.size();
	int count = 0,ans = 0;
	for(int i=0;i<N;i++){
		if(S[i]=='S') count++;
		else{
			if(count>=1) ans++;
			if(count>=1) count--;
		}
	}
	cout << N-2*ans << endl;
}