#include <bits/stdc++.h>
using namespace std;
string a;
int in;
int main() {
  cin >> a;
  int sz = a.size();
  int lasti;
  bool no = true;
  while (no) {
    char last = 'A';
    no = false;
    for (int i = 0; i < a.size(); i++) {
      if (last == 'S' && a[i] == 'T') {
        a[i] = 'A';
        a[lasti] = 'A';
        no = true;
        sz -= 2;
        last = 'A';
        i = i + 2;
      } else {
        if (a[i] != 'A') last = a[i], lasti = i;
      }
    }
  }
  printf("%d\n", sz);
}
