#include <bits/stdc++.h>
using namespace std;
int ans, i, n;
char st[210];
deque<char> dq;
int main() {
  scanf("%s", &st);
  n = strlen(st);
  for (i = 0; i < n; ++i) {
    if (st[i] == 'S')
      dq.push_back(st[i]);
    else {
      if (!dq.empty() && dq.back() == 'S') {
        dq.pop_back();
        while (!dq.empty() && dq.back() == 'T') {
          dq.pop_back();
          if (!dq.empty() && dq.back() == 'S')
            dq.pop_back();
          else {
            dq.push_front('T');
            break;
          }
        }
      } else
        dq.push_back(st[i]);
    }
    while (!dq.empty() && dq.front() == 'T') dq.pop_front(), ++ans;
  }
  while (!dq.empty()) dq.pop_back(), ++ans;
  printf("%d\n", ans);
  return 0;
}
