#include <bits/stdc++.h>
using namespace std;
namespace {}
int main() {
  string X;
  cin >> X;
  int numSt = 0;
  int iR(0);
  while (true) {
    int iR0 = iR;
    string::size_type indexL = X.find("ST", iR0);
    if (indexL == string::npos) {
      break;
    }
    ++numSt;
    int iL = indexL - 1;
    iR = indexL + 2;
    while (true) {
      if (iL < iR0) {
        break;
      }
      if (iR >= X.size()) {
        break;
      }
      if (X[iL] == 'S' && X[iR] == 'T') {
        ++numSt;
      } else {
        break;
      }
      --iL;
      ++iR;
    }
  }
  int numRest = X.size() - 2 * numSt;
  cout << numRest << endl;
  return 0;
}
