#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
using namespace std;
int main() {
  string s;
  cin >> s;
  int tops = 0;
  for (int i = 0; i < (s.size()); ++i) {
    if (s[i] == 'T')
      tops++;
    else
      break;
  }
  int tost = 0;
  for (int i = s.size() - 1; i >= 0; i--) {
    if (s[i] == 'S')
      tost++;
    else
      break;
  }
  cout << (max(tops, tost) * 2) << endl;
  ;
  return 0;
}
