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