#include <bits/stdc++.h>
using namespace std;
int main() {
  string X;
  cin >> X;
  int L = 0, Lcnt = 0;
  int R = X.size() - 1, Rcnt = 0;
  for (int i = 0; i < X.size(); i++) {
    if (X[i] != 'T') {
      L = i;
      break;
    }
    Lcnt++;
  }
  for (int i = X.size() - 1; i >= 0; i--) {
    if (X[i] != 'S') {
      R = i;
      break;
    }
    Rcnt++;
  }
  int Scnt = 0, Tcnt = 0;
  for (int i = L; i <= R; i++) {
    if (X[i] == 'S')
      Scnt++;
    else
      Tcnt++;
  }
  cout << Lcnt + Rcnt + abs(Scnt - Tcnt) << endl;
}
