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