#include <bits/stdc++.h>
using namespace std;
int l;
string s;
bool f = true;
int main() {
  cin >> s;
  l = s.length();
  while (f) {
    f = false;
    for (int i = 0; i < l - 1; i++) {
      if (s[i] == 'S' && s[i + 1] == 'T') {
        f = true;
        for (int j = i + 2; j < l; j++) s[j - 2] = s[j];
        l -= 2;
      }
    }
  }
  cout << l;
  return 0;
}
