#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-11;
int main(void) {
  string s;
  cin >> s;
  int sc = 0;
  int tc = 0;
  for (char c : s) {
    if (c == 'S') {
      sc++;
    } else if (c == 'T') {
      if (sc == 0) {
        tc++;
      } else {
        sc--;
      }
    }
  }
  cout << (sc + tc) << endl;
}
