#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  int n = s.size();
  int s1 = 0;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    s[i] = getchar();
    if (s[i] == 'S') s1 += 1;
    if (s1 && s[i] == 'T') {
      s1 -= 1;
      ans += 2;
    }
  }
  printf("%d\n", n - ans);
  return 0;
}
