#include <bits/stdc++.h>
using namespace std;
int dx[] = {-1, 0, 1, 0};
int dy[] = {0, -1, 0, 1};
template <class T, class F>
bool _mysort(pair<T, F> a, pair<T, F> b) {
  if (a.second != b.second)
    return a.second < b.second;
  else {
    return a.first < b.first;
  }
}
signed main(void) {
  cin.sync_with_stdio(false);
  cin.tie(0);
  string X;
  cin >> X;
  ;
  int tCount = 0, sCount = 0;
  for (int i = 0; i < X.length(); i++) {
    if (X[i] == 'S') break;
    tCount++;
  }
  for (int i = 0; i < X.length(); i++) {
    if (X[X.length() - 1 - i] == 'T') break;
    sCount++;
  }
  cout << max(tCount, sCount) * 2 << '\n';
  return 0;
}
