#include <bits/stdc++.h>
using namespace std;
int main() {
  string S;
  cin >> S;
  int cnt = 0;
  int sc = 0;
  bool del = false;
  for (int i = 0; i < S.length(); i++) {
    if (S[i] == 'T') {
      sc--;
    }
    if (S[i] == 'S') {
      if (i != 0 && S[i - 1] == 'T') {
        if (sc < 0) cnt -= sc;
        sc = 0;
      }
      sc++;
    }
  }
  cnt += sc;
  cout << cnt << endl;
}
