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