#include <bits/stdc++.h>
using namespace std;
int main() {
  string x;
  cin >> x;
  bool containST = true;
  while (containST && x.length() > 1) {
    containST = false;
    string reduced = "";
    int i = 0;
    while (i < x.length()) {
      if ((i < x.length() - 1) && x[i] == 'S' && x[i + 1] == 'T') {
        containST = true;
        i += 2;
      } else {
        reduced += x[i];
        i++;
      }
    }
    x = reduced;
  }
  cout << x.length();
}
