#include <bits/stdc++.h>
using namespace std;
int main() {
  string x;
  cin >> x;
  int num = 10000;
  for (double i = 0; i < num; i++)
    while (num--) {
      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());
          return 0;
        }
      } else {
        printf("%d\n", x.size());
        return 0;
      }
    }
  return 0;
}
