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