#include <bits/stdc++.h>
using namespace std;
int main() {
  char X[200001];
  scanf("%s\n", X);
  int i, length = 0, isUpdate = 0;
  while (X[length] != '\0') {
    length++;
  }
  while (1) {
    i = 0;
    isUpdate = 0;
    for (i = 0; i < length - 1; i++) {
      if (X[i] == 'S' && X[i + 1] == 'T') {
        for (; i < length - 1; i++) {
          X[i] = X[i + 2];
        }
        isUpdate = 1;
        break;
      }
    }
    if (isUpdate == 0) break;
  }
  int count;
  while (X[count] != '\0') {
    count++;
  }
  printf("%d\n", count);
  return 0;
}
