#include <bits/stdc++.h>
using namespace std;
int main(void) {
  string s;
  bool ans = false;
  cin >> s;
  int t = s.length();
  int i = 0;
  while (!ans) {
    if (i < t) {
      if (s[i] == 'S' && s[i + 1] == 'T') {
        s.erase(s.begin() + i, s.begin() + i + 2);
        t = s.length();
        i = 0;
      } else {
        i++;
      }
    } else {
      ans = true;
    }
  }
  cout << t << endl;
  return 0;
}
