#include <bits/stdc++.h>
using namespace std;
string s;
bool Solve() {
  string now;
  for (int i = 0; i < (int)s.size() - 1; ++i) {
    if (s[i] == 'S' && s[i + 1] == 'T') {
      i += 2;
      while (i < s.size()) now += s[i], ++i;
      s = now;
      return 1;
    }
    now += s[i];
  }
  return 0;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> s;
  while (Solve())
    ;
  cout << s.size() << '\n';
  return 0;
}
