#include <bits/stdc++.h>
using namespace std;
char c[200005];
int main() {
  scanf("%s", c);
  int k = strlen(c);
  while (1) {
    bool p = true, op = false;
    int ss = 200004;
    for (int i = 0; i < k; i++) {
      if (c[i] == 'S') ss = i, op = true;
      if (c[i] == 'T') {
        if (op) {
          c[i] = '0', c[ss] = '0', p = false;
        }
        op = false;
      }
    }
    if (p) break;
  }
  int ans = 0;
  for (int i = 0; i < k; i++) {
    if (c[i] == 'S' || c[i] == 'T') ans++;
  }
  printf("%d", ans);
}
