#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vd = vector<double>;
using vvd = vector<vd>;
const ll mod = ((ll)1e9) + 7;
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(50);
  string s;
  cin >> s;
  ll l = 0, r = s.size() - 1;
  while (s[l] == 'T') l++;
  while (s[r] == 'S') r--;
  ll ma = max<ll>(l, s.size() - r - 1);
  cout << ma * 2 << endl;
  return 0;
}
