#include <bits/stdc++.h>
using namespace std;
string s;
string search = "ST";
int main() {
  ios::sync_with_stdio(false);
  cin >> s;
  size_t found = s.find("ST");
  while (found != string::npos) {
    string temp = s.substr(0, found);
    temp.append(s.substr(found + 2, s.length() - found + 2));
    s = temp;
    found = s.find("ST");
  }
  cout << s.length() << endl;
  return 0;
}
