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