#include <bits/stdc++.h>
int main() {
  char *str = new char[200000];
  std::stack<char> rst;
  scanf("%s", str);
  int i = 0;
  int size = static_cast<int>(strlen(str));
  bool is_empty = true;
  while (i < size) {
    if (is_empty) {
      is_empty = false;
      rst.push(str[i]);
    } else if (str[i] == 'T') {
      if (!is_empty && rst.top() == 'S')
        rst.pop();
      else
        rst.push(str[i]);
    } else
      rst.push(str[i]);
    i++;
  };
  printf("%d\n", rst.size());
  delete[] str;
  return 0;
}
