#include <bits/stdc++.h>
using namespace std;
int main(int argc, char** argv) {
  std::ios::sync_with_stdio(false);
  string str;
  cin >> str;
  int i = 0;
  int len = str.length();
  while (i < len) {
    if (str[i] == 'S' && str[i + 1] == 'T') {
      int c = i;
      while (c + 2 < len) {
        str[c] = str[c + 2];
        ++c;
      }
      len -= 2;
    }
    ++i;
  }
  cout << len << endl;
  return 0;
}
