#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
char a[N];
int main() {
  cin >> a;
  int n = strlen(a);
  int len = 0;
  int l = 0;
  int r = n - 1;
  while (a[l] == 'T') {
    l++;
  }
  while (a[r] == 'S') {
    r--;
  }
  len = abs(n - l - r - 1);
  len = len + l + n - 1 - r;
  cout << len;
}
