#include <bits/stdc++.h>
using namespace std;
int main() {
  string str;
  getline(cin, str);
  int n = str.length();
  bool flag = 1;
  while (flag) {
    flag = 0;
    for (int i = 0; i < n; i++) {
      if (str[i] == 'S' && str[i + 1] == 'T') {
        str = str.replace(i, 2, "");
        n = str.length();
        flag = 1;
        break;
      }
    }
  }
  if (str == "")
    cout << 0 << endl;
  else
    cout << str.length() << endl;
  return 0;
}
