#include <bits/stdc++.h>
using namespace std;
template <typename T>
void cins(vector<T>& arr) {
  for (T& e : arr) cin >> e;
}
int main(void) {
  string str;
  cin >> str;
  int t = 0;
  for (int i = 0; i < str.length(); i++) {
    if (str[i] == 'S') break;
    t++;
  }
  int s = 0;
  for (int i = str.length() - 1; i >= 0; i--) {
    if (str[i] == 'T') break;
    s++;
  }
  int pair = max(s, t);
  cout << pair * 2 << endl;
  return 0;
}
