#include <bits/stdc++.h>
using namespace std;
const int N = 2 * 1e5 + 10;
char str[N];
int pre[N];
int r, l, length;
void strMinus(int n) {
  length -= 2;
  pre[r] = pre[l] = pre[l - 1] == -1 ? l - 1 : pre[l - 1];
  r++;
  l = pre[l - 1] == -1 ? l - 1 : pre[l - 1];
  while (l >= 0 && r <= n - 1 && str[l] == 'S' && str[r] == 'T') {
    length -= 2;
    pre[r] = pre[l] = pre[l - 1] == -1 ? l - 1 : pre[l - 1];
    r++;
    l = pre[l - 1] == -1 ? l - 1 : pre[l - 1];
  }
  return;
}
int main() {
  for (int i = 0; i < N; i++) pre[i] = -1;
  scanf("%s", str);
  length = strlen(str);
  int i = 0;
  while (i <= length - 1) {
    if (str[i] == 'S' && str[i + 1] == 'T') {
      r = i + 1, l = i;
      strMinus(strlen(str));
      i = r - 1;
    }
    i++;
  }
  printf("%d", length);
  return 0;
}
