#include <bits/stdc++.h>
using namespace std;
int main() {
  string x;
  cin >> x;
  int scount = 0;
  int tcount = 0;
  bool sflg = true;
  for (int i = x.size() - 1; i >= 0; i--) {
    if (sflg) {
      if (x[i] == 'S') {
        scount++;
      } else {
        sflg = false;
        tcount++;
      }
    } else {
      if (x[i] == 'T') {
        tcount++;
      } else {
        tcount--;
      }
    }
  }
  cout << scount + tcount << endl;
  return 0;
}
