#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int m = 0;
  m = s.size();
  int i = 0;
  while (i != m - 2) {
    if (s[i] == 'S' && s[i + 1] == 'T') {
      s.erase(s.begin() + i);
      s.erase(s.begin() + i);
      i = 0;
      m -= 2;
    } else {
      i++;
    }
  }
  if (s == "ST") {
    m -= 2;
  }
  cout << m;
  return 0;
}
