#include <bits/stdc++.h>
using namespace std;
const int N = 200010;
int n;
char a[N];
int main() {
  scanf("%s", a + 1);
  n = strlen(a + 1);
  int num = 0, ans = n;
  for (int i = 1; i <= n; i++) {
    if (a[i] == 'T')
      if (num > 0)
        num--, ans -= 2;
      else
        num++;
  }
  printf("%d\n", ans);
  return 0;
}
