#include <bits/stdc++.h>
using namespace std;
const int maxn = 200010;
struct At {
  char c;
  At* last;
  At* next;
} c[maxn];
int main() {
  string s;
  cin >> s;
  int size = s.size();
  c[0] = {s[0], NULL, &c[1]};
  for (int i = 1; i < size - 1; i++) {
    c[i] = {s[i], &c[i - 1], &c[i + 1]};
  }
  c[size - 1] = {s[size - 1], &c[size - 2], NULL};
  int t = maxn;
  At* now = &c[0];
  while (true) {
    for (At* i = now; i->next != NULL; i = i->next) {
      if (i->c == 'S' && i->next->c == 'T') {
        At* lastNode = i->last;
        At* nextNode = i->next->next;
        if (lastNode != NULL) {
          now = lastNode;
          lastNode = nextNode;
          if (nextNode != NULL) nextNode->last = lastNode;
        } else {
          now = nextNode;
          if (nextNode != NULL) nextNode->last = NULL;
        }
        size -= 2;
        break;
      }
    }
    if (size == 0 || now == NULL) break;
  }
  cout << size << endl;
  return 0;
}
