#include <bits/stdc++.h>
using namespace std;
const int INF = (1 << 30);
const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
int main() {
  string X;
  int ans;
  cin >> X;
  ans = X.size();
  int S = 0, T = 0;
  for (int i = 0; i < (X.size()); i++) {
    if (X[i] == 'S') {
      S++;
    } else {
      T++;
      if (S == T) {
        ans -= (S + T);
        S = T = 0;
      } else if (S < T) {
        S = T = 0;
      }
    }
  }
  if (S && T) ans += (S - T) * 2;
  cout << ans << endl;
}
