#include <bits/stdc++.h>
using namespace std;
int main() {
  int count = 100000;
  string x;
  cin >> x;
  int len = x.length();
  for (int i = 0; (i < len && count > 0);) {
    if (x[i] == 'S' && x[i + 1] == 'T') {
      x.replace(i, 2, "");
      count--;
      i = 0;
    } else {
      i++;
    }
  }
  int result = x.length();
  printf("%d\n", result);
  return 0;
}
