#include<bits/stdc++.h>
using namespace std;
stack<int>s;
int main()
{
    char ch;
    int ans=0;
    while(cin>>ch)
	{
        ans++;
        if(ch=='S') s.push(1);
        else 
		    if(!s.empty()) 
			    s.pop(),ans-=2;
    }
    cout<<ans<<endl;
    return 0;
}