#include <bits/stdc++.h>
using namespace std;
string ch;
int kk = 0, hh;
int main() {
  cin >> ch;
  hh = ch.size();
  for (int i = 1; i <= ch.size() / 2; i++)
    for (int j = 0; j < ch.size() - i; j++) {
      for (int k = j; k < j + i; k++)
        if (ch[k] != 'S') {
          kk = 1;
          break;
        }
      if (kk != 1) {
        for (int k = j + i; k <= j + i + i; k++)
          if (ch[k] != 'T') {
            kk = 1;
            break;
          }
        if (kk == 0) {
          hh = hh - i * 2;
        }
        kk = 0;
      }
      kk = 0;
    }
  cout << hh;
  return 0;
}
