#include <bits/stdc++.h>
int main() {
  std::string s;
  std::cin >> s;
  int c = 0, a = 0;
  for (auto t : s) {
    if (t == 'S') {
      c--;
      break;
    }
    if (c >= 0) a++;
    if (c != 0) c++;
  }
  std::cout << 2 * a;
}
