#include <bits/stdc++.h>
using namespace std;
string aa;
long long i = 0, a = 0, b = 0, c;
signed main() {
  cin >> aa;
  while (1) {
    if (aa[i] == 'S') {
      break;
    } else {
      a++;
    }
    i++;
  }
  i = aa.size();
  while (1) {
    i--;
    if (aa[i] == 'T') {
      break;
    } else {
      b++;
    }
  }
  cout << max(a, b) * 2;
}
