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