#include <bits/stdc++.h>
using namespace std;
const int N = 200500;
char a[N];
int main() {
  int flag = 1;
  gets(a);
  int size;
  while (flag == 1) {
    size = strlen(a);
    for (int i = 0; i < size; i++) {
      if (a[i] == 'S' && a[i + 1] == 'T') {
        flag = 1;
        for (int j = i; j < size; j++) a[j] = a[j + 2];
        goto mark;
      } else {
        flag = 0;
      }
    }
  mark:
    size = strlen(a);
    if (size == 2 && a[0] == 'S' && a[1] == 'T') {
      printf("0\n");
      return 0;
    }
  }
  printf("%d\n", size);
  return 0;
}
