#include <bits/stdc++.h>
using namespace std;
int main() {
  string str;
  cin >> str;
  int pos, len;
  len = str.size();
  for (int i = 0; i < len / 2; i++) {
    pos = str.find("ST");
    if (pos != -1)
      str.erase(pos, 2);
    else if (pos == -1)
      break;
  }
  int ans = str.size();
  printf("%d\n", ans);
  return 0;
}
