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