#include <bits/stdc++.h>
using namespace std;
string str;
int main() {
  cin >> str;
  int m, flag = 0;
  while (flag == 0) {
    m = str.find("ST");
    if (m < 0)
      flag = 1;
    else
      str.erase(m, 2);
  }
  int n = str.size();
  printf("%d\n", n);
  return 0;
}
