#include<iostream>
#include<cstring>
using namespace std;
#define MAX 200200
char ch[MAX];
int ans,tot;
int main()
{
    cin>>(ch+1);
    for(int i=1,l=strlen(ch+1);i<=l;++i)
        if(ch[i]=='S')++tot;
        else tot?--tot:++ans;
    cout<<ans+tot<<endl;
        return 0;
}