#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c, d, cou = 0, flag = 0;
  string s;
  cin >> s;
  for (;;) {
    cou = 0;
    for (int i = 0; i < s.size(); i++) {
      if (s[i] == 'S') {
        flag = 1;
      } else if (flag == 1 && s[i] == 'T') {
        s.erase(s.begin() + i - 1);
        s.erase(s.begin() + i - 1);
        flag = 0;
        cou = 1;
        i = i - 1;
      } else {
        flag = 0;
      }
    }
    if (cou == 0) break;
  }
  cout << s.size() << endl;
  return 0;
}
