#include <bits/stdc++.h>
using namespace std;
int main() {
  string str = "";
  cin >> str;
  int len = str.length();
  for (int i = 0; i < len - 1; i++) {
    if (str[i] == 'S' && str[i + 1] == 'T') {
      str.erase(str.begin() + i, str.begin() + i + 2);
      len -= 2;
      i = -1;
    }
  }
  cout << str.length() << endl;
  return 0;
}
