#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int tcnt = 0, scnt = 0, cnt = 0;
  for (int i = 0; i < s.size(); ++i) {
    if (s[i] == 'S') {
      if (!tcnt) scnt = 0, tcnt = 0;
      scnt++;
    } else {
      if (tcnt < scnt) cnt++;
      tcnt++;
    }
  }
  cout << s.size() - cnt << endl;
  return 0;
}
