#include <bits/stdc++.h>
using namespace std;
int main() {
  string X;
  cin >> X;
  int numSt = 0;
  while (true) {
    int iL = 0;
    bool isFound = false;
    for (int iL = 0; iL <= X.size() - 2; ++iL) {
      if (X[iL] == 'S') {
        for (int iR = iL + 1; iR <= X.size() - 1; ++iR) {
          if (X[iR] == 'T') {
            X[iL] = 'x';
            X[iR] = 'x';
            ++numSt;
            isFound = true;
            break;
          } else if (X[iR] == 'S') {
            break;
          }
        }
      }
    }
    if (isFound == false) {
      break;
    }
  }
  cout << X.size() - numSt * 2 << endl;
  return 0;
}
