#include<bits/stdc++.h>
using namespace std;
string s;
int sum1,sum2,sum;
int main()
{
    cin>>s;
    int n=s.size();
    for(int i=0;i<n;i++)
    {
        if(s[i]=='S') sum2++;
        if(sum2>=sum1)
        else if(sum2) sum1++;
        {
            sum+=min(sum2,sum1)*2;
            sum2-=min(sum2,sum1);
            sum1=0;
        }
    }
    cout<<n-sum<<endl;
    return 0;
}