#include <bits/stdc++.h>
using namespace std;

int main() {
  string X;
  cin >> X;
  int sc = 0, ans = X.size();
  for (char c : X) {
    if (c == 'S') sc++;
    else if (0 < sc) {
      sc--;
      ans -= 2;
    }
  }
  cout << ans << endl;
}