#include <bits/stdc++.h>
using namespace std;
int main() {
  string str;
  cin >> str;
  int scnt = 0, tcnt = 0;
  int beg = str.find_first_of('S');
  int end = str.find_last_of('T');
  if (beg == string::npos || end == string::npos) {
    printf("%d\n", (int)str.size());
    return 0;
  }
  int ans = (int)str.size();
  for (int i = beg; i <= end; ++i) {
    if (str[i] == 'S')
      ++scnt;
    else
      ++tcnt;
  }
  printf("%d\n", ans - min(scnt, tcnt) * 2);
}
