#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int A[N], n;
char s[N];
int main() {
  scanf("%s", s);
  n = strlen(s);
  for (int i = 0; i < n; i++) A[i] = (s[i] == 'T');
  for (int i = 0; i < n - 1; i++) {
    if (i < 0) continue;
    if (!A[i] && A[i + 1]) {
      for (int j = i; j + 2 < n; j++) A[j] = A[j + 2];
      i -= 2;
      n -= 2;
    }
  }
  printf("%d", n);
}
