#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int a = s.find("ST");
  do {
    s.erase(a, 2);
    a = s.find("ST");
  } while (a != string::npos);
  cout << s.length();
  return 0;
}
