#include <bits/stdc++.h>
using namespace std;
typedef struct lnod {
  char c;
  lnod *left, *right;
} * nod;
int rs, i;
string s;
nod root, last;
int main() {
  ios_base::sync_with_stdio(0);
  cin >> s;
  for (i = 0; i < (int)s.size(); ++i) {
    nod p = new lnod;
    p->c = s[i];
    if (!root) {
      root = p;
      root->left = NULL;
      root->right = NULL;
      last = root;
    }
    p->left = last;
    p->right = NULL;
    last->right = p;
    last = p;
  }
  for (nod p = root; p->right;) {
    if (p->c == 'S' && p->right->c == 'T') {
      nod now = p->left;
      p->left->right = p->right->right;
      p = now;
      continue;
    }
    p = p->right;
  }
  for (nod p = root; p; p = p->right) ++rs;
  cout << rs << '\n';
  return 0;
}
