#include <bits/stdc++.h>
using namespace std;
#define ll long long

string x;

int main(){
  cin >> x;
  ll pos = 0;
  ll ans = 0;
  while(1){
    if(x == "ST"){
      cout << 0 << endl;
      return 0;
    }
    while(pos + 1 < x.length() && x.substr(pos,2) != "ST"){
      pos++;
    }
    if(pos + 1 == x.length()){
      cout << x.length() << endl;
      return 0;
    }else{
      cout << "newstring: " << newstring << endl;
      x = newstring;
      pos--;
    }
  }
}
