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