#include <bits/stdc++.h>
using namespace std;
int main(int argc, char** argv) {
  string str;
  cin >> str;
  bool flag = true;
  while (flag == true) {
    flag = false;
    int len = str.size();
    for (int i = 0; i < len - 1; i++) {
      string new_S;
      if (str[i] == 'S' && str[i + 1] == 'T') {
        str[i] = '.';
        str[i + 1] = '.';
        flag = true;
        for (int i2 = 0; i2 < len; i2++) {
          if (str[i2] != '.') {
            new_S += str[i2];
          }
        }
      }
      str = new_S;
    }
  }
  cout << str.size();
  return 0;
}
