#include <bits/stdc++.h>
using namespace std;
int main() {
  string str;
  cin >> str;
  list<char> lc(str.begin(), str.end());
  bool change = true;
  while (change) {
    change = false;
    for (auto it2 = ++lc.begin(), it1 = lc.begin(); it2 != lc.end();
         ++it1, ++it2) {
      if (*it1 == 'S' && *it2 == 'T') {
        lc.erase(it1);
        lc.erase(it2);
        change = true;
        break;
      }
    }
  }
  printf("%d\n", (int)lc.size());
}
