#include <bits/stdc++.h>
using namespace std;
int main() {
  char X[200001];
  scanf("%s", X);
  string str_X(X);
  int counter = 0;
  set<int> S;
  set<int> T;
  for (int i = 0; i < str_X.length(); i++) {
    if (str_X[i] == 'S') {
      S.insert(i);
    } else if (str_X[i] == 'T') {
      T.insert(i);
    }
  }
  while (T.size() > 0) {
    bool found = false;
    for (int i = 1; i <= str_X.length(); i += 2) {
      for (set<int>::iterator iterT = T.begin(); iterT != T.end(); iterT++) {
        if (*iterT < i) {
          continue;
        }
        if (S.find((*iterT) - i) != S.end()) {
          found = true;
          T.erase(*iterT);
          S.erase((*iterT) - i);
          break;
        } else if (T.find((*iterT) - i) != T.end()) {
          break;
        }
        if (found) {
          break;
        }
      }
    }
    if (!found) {
      break;
    }
  }
  cout << (S.size() + T.size()) << endl;
  return 0;
}
