#include <bits/stdc++.h>
using namespace std;
int main() {
  string x;
  x.reserve(200000);
  cin >> x;
  int32_t Scount{0}, count{0};
  bool is_first_S{true};
  for (auto i{0}; i < x.size(); ++i) {
    if (x[i] == 'S') {
      Scount = is_first_S ? 1 : Scount + 1;
      is_first_S = false;
    } else {
      count += Scount-- > 0 ? 1 : 0;
    }
  }
  cout << count << endl;
}
