#include <bits/stdc++.h>
using namespace std;
class Node {
 public:
  char val;
  Node *next;
  Node(int val) { this->val = val; }
};
class Stack {
 public:
  int size;
  Node *top;
  Stack() {
    size = 0;
    top = NULL;
  }
  void push(char val) {
    Node *nd = new Node(val);
    nd->next = top;
    top = nd;
    size++;
  }
  void pop() {
    if (top != NULL) {
      top = top->next;
      size--;
    }
  }
  int getsize() { return size; }
};
string X;
Stack *st = new Stack;
int t = 1010000;
int main() {
  cin >> X;
  if (X.length() % 2 == 0 && X.length() <= 2 && X.length() >= 200 && t != 0) {
    for (int i = 0; i < X.length(); i++) {
      if (X[i] == 'S') {
        st->push(X[i]);
      }
      if (X[i] == 'T') {
        if (st->getsize() > 0 && st->top->val == 'S') {
          st->pop();
          t--;
        }
        st->push(X[i]);
      }
    }
  }
  cout << st->getsize() - 1;
}
