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