#include <bits/stdc++.h>
using namespace std;
int main() {
  string str;
  cin >> str;
  bool flag = true;
  int N = str.size() - 1;
  size_t st;
  while ((st = str.find("ST")) != string::npos) {
    str.erase(st, 2);
  }
  cout << str.size() << endl;
  return 0;
}
