
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
#include <regex>


using namespace std;
typedef long long ll;

string s;
string search = "ST";

std::regex reg(R"(\{ST\}+)");


int main() {
    ios::sync_with_stdio(false);
    
    cin >> s;
    s = regex_replace(s, r, "");
    
        size_t found = s.find("ST");
    
    //cout << found << endl;
    
    while (found != string::npos) {
        string temp = s.substr(0,found);
        temp.append(s.substr(found+2, s.length()-found+2));
        s = temp;
        s = regex_replace(s, r, "");
        found = s.find("ST");
    }
    //*/
    
    cout << s.length() << endl;
    
    
    return 0;

}
