#include <bits/stdc++.h>
using namespace std;
int main() {
  string x;
  cin >> x;
  int num = 10000;
  int flag = 1;
  while (flag) {
    if (x.size() >= 2) {
      bool ok = false;
      for (int i = 0; i + 1 < x.size(); i++) {
        if (x[i] == 'S' && x[i + 1] == 'T') {
          ok = true;
          x.erase(i, 2);
          break;
        }
      }
      if (ok == false) {
        printf("%d\n", x.size());
        flag = 0;
      }
    } else {
      printf("%d\n", x.size());
      flag = 0;
    }
  }
  return 0;
}
