#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5;
char str[maxn], c;
int n;
int main() {
  n = 0;
  while ((c = getchar()) != '\n') {
    str[n] = c;
    n++;
  }
  int l = 0, f = 0;
  while (l + 1 < n) {
    if (str[l] == 'S' && str[l + 1] == 'T') {
      for (int i = l + 2; i < n; i++) {
        str[l] = str[l + 2];
      }
      l = 0;
      f++;
    } else
      l++;
  }
  printf("%d\n", n - f * 2);
  return 0;
}
