#include <bits/stdc++.h>
using namespace std;
int main() {
  string str, st;
  int mem, x, new_len;
  while (cin >> str) {
    mem = str.length();
    while (true) {
      x = str.find("ST");
      if (x < 0 || x > mem) break;
      str.replace(x, 2, "");
      new_len = str.length();
      if (new_len == 0 || new_len == mem) break;
      mem = new_len;
    }
    cout << new_len << endl;
  }
  return 0;
}
