#include <bits/stdc++.h>
using namespace std;
string s;
int i, n, m, j, k, l, r;
int main() {
  cin >> s;
  n = s.size();
  for (i = 0; i < n; i++) {
    if (s[i] == 'S') break;
    l++;
  }
  for (i = n - 1; i >= 0; i--) {
    if (s[i] == 'T') break;
    r++;
  }
  cout << max(l, r) * 2;
  return 0;
}
