#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
string S;
int main() {
  cin >> S;
  ll N = S.length();
  ll left = 0, right = 0;
  for (int i = 0; i < N && S[i] == 'T'; ++i) {
    ++left;
  }
  for (int i = N - 1; i >= 0 && S[i] == 'S'; --i) {
    ++right;
  }
  cout << max(left, right) * 2 << endl;
}
