#include <bits/stdc++.h>
using namespace std;
int main() {
  string str;
  cin >> str;
  int scnt = 0, tcnt = 0, total = 0, left = 0, right = 0;
  bool flag = true;
  for (int i = 0; i < str.size(); i++) {
    if (str[i] == 'T') {
      left++;
    } else {
      break;
    }
  }
  for (int i = str.size() - 1; i >= 0; i--) {
    if (str[i] == 'S') {
      right++;
    } else {
      break;
    }
  }
  cout << max(left, right) * 2 << endl;
}
