#include <bits/stdc++.h>
using namespace std;
int main() {
  string X;
  cin >> X;
  int a = X.size();
  for (int i = 0; i < 100000; i++) {
    if (X.empty()) break;
    for (auto it = next(X.begin()); it != X.end(); it++) {
      if (*prev(it) == 'S' && *it == 'T') {
        a -= 2;
        it = X.erase(it - 1);
        X.erase(it);
        break;
      }
    }
  }
  cout << a << endl;
  return 0;
}
