#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  int a;
  cin >> s;
  while (1) {
    a = s.find("ST");
    if (a == -1) break;
    if (a == 0)
      s = s.substr(a + 2);
    else if (a + 2 > s.length())
      s = s.substr(0, a);
    else
      s = s.substr(0, a) + s.substr(a + 2);
  }
  cout << s.length() << endl;
  return 0;
}
