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