#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
const double PI = 3.14159265358979;
const ll INF = pow(10, 18);
string abc = "abcdefghijklmnopqrstuvwxyz";
string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge {
  ll to, cost;
};
int main() {
  string x;
  cin >> x;
  ll n = x.size();
  ll s = 0;
  ll t = 0;
  while (x[t] == 'T') {
    t++;
  }
  while (x[n - 1 - s] == 'S') {
    s++;
  }
  cout << 2 * max(s, t) << endl;
}
