#include <iostream>
#include <cstring>
#include <algorithm>
#define REP(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(typeof(a) i=a;i!=(b);++i)
#define CLEAR(a,v) memset(a,v,sizeof(a))
#define SORT(a) sort(a,a+sizeof(a)/sizeof(a[0]))
using namespace std;

int main(){
    string S;
    cin >> S;
    int s = 0, t = 0;
    int len = S.size();
    REP(i,len){
        if(S[i] == 'S'){
            s++;
        }else{
            if(s == 0){
                t++;
            }else{
                s--;
            }
        }
    }
    cout << s+t << endl;r
}