#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
const long long int linf = 1LL << 50;
const double EPS = 1e-10;
int main(int argc, char const* argv[]) {
  string s;
  cin >> s;
  int start = 0;
  while (true) {
    if (start == s.size()) break;
    if (s[start] == 'T')
      start++;
    else {
      if (start < s.size() - 1 && s[start + 1] == 'T') {
        s = s.substr(0, start) + s.substr(start + 2, s.size() - start - 2);
        start--;
        if (start < 0) start = 0;
      } else {
        start++;
      }
    }
  }
  cout << s.size() << endl;
  return 0;
}
