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