#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int ans = 0;
  bool up = true;
  while (up) {
    int p = 0;
    int n_s = 0;
    int n_t = 0;
    int start;
    for (; p < s.size() && s[p] != 'S'; p++) {
    }
    start = p;
    for (; p < s.size() && s[p] != 'T'; p++) n_s++;
    for (; p < s.size() && s[p] != 'S'; p++) n_t++;
    int tmp = n_t > n_s ? n_s : n_t;
    if (tmp == 0) {
      up = false;
    } else {
      s = s.replace(start, tmp * 2, "");
    }
  }
  cout << s.size() << endl;
  return 0;
}
