#include <bits/stdc++.h>
using namespace std;
int main() {
  int cnt = 0, cntmax = 0;
  string S;
  cin >> S;
  int ans = S.length();
  for (int i = 0; i < S.length(); i++) {
    if (S[i] == 'S')
      cnt++;
    else
      cnt--;
    if (cnt < 0) cnt = 0;
    if (cnt > cntmax) cntmax = cnt;
    if (cnt == 0) {
      ans -= cntmax * 2;
      cntmax = 0;
    }
  }
  cout << ans << endl;
  return 0;
}
