#include <bits/stdc++.h>
using namespace std;
int main() {
  string x;
  cin >> x;
  string st = "ST";
  while (1) {
    size_t pos = x.find(st);
    if (pos == -1) {
      cout << x.length() << endl;
      break;
    }
    x.erase(x.begin() + pos, x.begin() + pos + st.length());
  }
}
