#include <bits/stdc++.h>
using namespace std;
string s;
int main() {
  cin >> s;
  if (s[0] == 'S')
    cout << 0 << endl;
  else {
    int num[2] = {};
    for (long long i = 0; i < (s.size()); i++) {
      if (s[i] == 'S') break;
      num[0]++;
    }
    for (int i = s.size() - 1; i >= 0; i--) {
      if (s[i] == 'T') break;
      num[1]++;
    }
    cout << max(num[0], num[1]) * 2 << endl;
  }
}
