#include <bits/stdc++.h>
using namespace std;
int main() {
  string str;
  scanf("%s", &str[0]);
  int flag = 1;
  while (flag == 1) {
    if (str.empty()) break;
    int i = 0;
    flag = 0;
    while (i < str.length() - 1) {
      if (str[i] == 'S' && str[i + 1] == 'T') {
        str.erase(i, 2);
        flag = 1;
        break;
      }
      ++i;
    }
  }
  printf("%d\n", str.length());
  return 0;
}
