#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-10;
const double pi = acos(-1.0);
const double inf = (int)1e8;
int main() {
  string s;
  std::cin >> s;
  bool b = false;
  string::size_type pos = s.find("ST");
  while (pos != string::npos) {
    s.replace(pos, 2, "");
    pos = s.find("ST");
  }
  std::cout << s.size() << std::endl;
}
