#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int n;
char s[N];
vector<char> v;
int main() {
  scanf("%s", s);
  n = strlen(s);
  for (int i = 0; i < n; i++) {
    v.push_back(s[i]);
    size_t sz = v.size();
    if (sz >= 2) {
      if (v[sz - 2] == 'S' && v[sz - 1] == 'T') {
        v.pop_back();
        v.pop_back();
      }
    }
  }
  printf("%u\n", v.size());
  return 0;
}
