#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, n, j, temp;
  string a;
  getline(cin, a);
  n = a.length();
  for (i = 0; i < n; i++) {
    if (a[i] == 'S' && a[i + 1] == 'T') {
      for (j = i; j < n; j++) {
        temp = a[j];
        a[j] = a[j + 2];
        a[j + 2] = temp;
      }
      n = n - 2;
      i = -1;
    }
  }
  printf("%d", n);
  return 0;
}
