#include <bits/stdc++.h>
using namespace std;
int main() {
  string s, exs;
  cin >> s;
  exs.clear();
  int flag = 1;
  while (flag) {
    flag = 0;
    for (int i = 0; i < s.size() - 1; i++)
      if (s[i] == 'S' && s[i + 1] == 'T') {
        i++;
        flag = 1;
      } else
        exs += s[i];
    s = exs;
  }
  cout << s.size() << endl;
}
