#include <bits/stdc++.h>
using namespace std;
int main() {
  string x;
  cin >> x;
  vector<bool> flg(x.length(), false);
  string ans;
  for (int i = 0; i < (x.length()); ++i) {
    if (i < x.length() - 1 && x[i] == 'S' && x[i + 1] == 'T') {
      flg[i] = true;
      flg[i + 1] = true;
      int l = i - 1;
      int r = i + 2;
      while (1) {
        if (l < 0 || r >= x.length()) break;
        if (x[l] != 'S' || x[r] != 'T') break;
        flg[l] = true;
        flg[r] = true;
        --l, ++r;
      }
    }
  }
  for (int i = 0; i < (x.length()); ++i) {
    if (!flg[i]) ans += x[i];
  }
  cout << ans.length() << endl;
  return 0;
}
