#include <bits/stdc++.h>
using namespace std;
int main() {
  string X;
  cin >> X;
  int cntLeftT = 0, cntRightS = 0;
  int indexS, indexE;
  for (int i = 0; i < X.length(); i++) {
    if (X[i] == 'S') {
      indexS = i;
      break;
    } else if (X[i] == 'T')
      cntLeftT++;
  }
  for (int i = X.length(); i >= 0; i--) {
    if (X[i] == 'S')
      cntRightS++;
    else if (X[i] == 'T') {
      indexE = i;
      break;
    }
  }
  int len = X.length() / 2;
  int cntS = len - cntRightS, cntT = len - cntLeftT;
  int res = cntS + cntT;
  int ans = cntLeftT + cntRightS + res - min(cntS, cntT) * 2;
  cout << ans << endl;
  return 0;
}
