#include <bits/stdc++.h>
using namespace std;
long long dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
long long dy[] = {0, 1, 0, -1, 1, 1, -1, -1};
string X;
signed main() {
  cin >> X;
  long long ans = X.length();
  bool cur_S = true;
  long long depth = 0;
  for (long long i = 0; i < X.length(); i++) {
    if (X[i] == 'S') {
      if (cur_S) {
        depth++;
      } else {
        depth = 1;
      }
      cur_S = true;
    } else {
      if (depth > 0) {
        depth--;
        ans -= 2;
      }
      cur_S = false;
    }
  }
  cout << ans << endl;
}
