#include <bits/stdc++.h>
using namespace std;
int main() {
  string str;
  cin >> str;
  while (1) {
    int lens = str.length();
    for (int i = 0; i <= str.length() - 2; i++) {
      if (str.substr(i, 2) == "ST") {
        str.erase(i, 2);
        i--;
      }
      if (!str.length()) break;
    }
    if (lens == str.length())
      break;
    else
      lens = str.length();
  }
  if (str.size())
    cout << str.size() << endl;
  else
    cout << 0 << endl;
  return 0;
}
