#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int len = s.length();
  int ns = 0;
  int cnt = 0;
  int bef = 0;
  int rest = 0;
  for (int i = 0; (i) < (len); (i)++) {
    if (rest >= 10000) break;
    if (s[i] == 'S') {
      if (bef == 0)
        ns++;
      else {
        ns = 1;
        bef = 0;
      }
    }
    if (s[i] == 'T') {
      if (ns > 0) {
        ns--;
        cnt++;
        bef = 1;
      } else {
        bef = 0;
      }
    }
    rest++;
  }
  cout << len - 2 * cnt << endl;
  return 0;
}
