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