#include <bits/stdc++.h>
using namespace std;
int l, r;
string s;
int main() {
  cin >> s;
  l = 0;
  r = 0;
  while (s.front() == 'T') {
    l += 2;
    s.erase(0, 1);
  }
  while (s.back() == 'S') {
    r += 2;
    s.pop_back();
  }
  cout << ((l > r) ? l : r) << endl;
}
