#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const long long LINF = 1LL << 60;
const int INF = 1 << 30;
int main() {
  string s;
  cin >> s;
  int n = s.size();
  int sub1 = 0;
  for (int i = 0; i < n; i++) {
    if (s[n - i - 1] == 'S')
      sub1++;
    else
      break;
  }
  int sub2 = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'T')
      sub2++;
    else
      break;
  }
  cout << 2 * max(sub1, sub2) << endl;
  return 0;
}
