#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pl4 = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using vvs = vector<vs>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vpii = vector<pii>;
using vvpii = vector<vpii>;
using vpl4 = vector<pl4>;
using vvpl4 = vector<vpl4>;
const ll MOD = 1e9 + 7;
const string alp = "abcdefghijklmnopqrstuvwxyz";
const string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll salv(vll v) {
  cout << ("{");
  ;
  for (ll i = (0); i <= (v.size() - 1); i++) {
    cout << (v[i]);
    ;
    if (i != v.size() - 1) cout << (",");
    ;
  }
  cout << ("}") << endl;
}
ll DigS10(ll n) {
  ll m = 0;
  for (ll i = (0);
       i <= (((llabs(n) == 0) ? (1) : ((ll)(log10(double(llabs(n)))) + 1)) - 1);
       i++) {
    m += (ll)((llabs(n) % (ll)(pow(10.0, (double)(i + 1)))) /
              (ll)(pow(10.0, (double)i)));
  }
  return m;
}
ll isP(ll n) {
  if (n <= 1) return 0;
  for (ll i = (2); i <= ((ll)sqrt(n)); i++) {
    if (n % i == 0) return 0;
  }
  return 1;
}
vll FactM(1, 1);
vll FactMI(1, 1);
ll PowM(ll a, ll b) {
  ll ans = 1, x = (a % MOD);
  for (ll i = (0);
       i <= (((llabs(b) == 0) ? (1) : ((ll)(log2(double(llabs(b)))) + 1)) - 1);
       i++) {
    if ((((b) >> (i)) & 1) == 1) ans = (ans * x) % MOD;
    if (i != (((llabs(b) == 0) ? (1) : ((ll)(log2(double(llabs(b)))) + 1)) - 1))
      x = (x * x) % MOD;
  }
  return ans;
}
void CFactM(ll n) {
  for (ll i = (FactM.size()); i <= (n); i++) {
    FactM.push_back((FactM[i - 1] * (i % MOD)) % MOD);
  }
  return;
}
void CFactMI(ll n) {
  CFactM(n);
  if (FactMI.size() < (n + 1)) FactMI.resize(n + 1, -1);
  if (FactMI[n] == -1) FactMI[n] = PowM(FactM[n], MOD - 2);
  for (ll i = (n - 1); i >= (1); i--) {
    if (FactMI[i] != -1) break;
    FactMI[i] = ((FactMI[i + 1] * ((i + 1) % MOD)) % MOD);
  }
  return;
}
ll CombM(ll n, ll k) {
  if ((n < 0) || (k < 0)) return 0;
  if (n < k) return 0;
  if (n + 1 > FactMI.size()) CFactMI(n);
  return ((((FactMI[k] * FactMI[n - k]) % MOD) * FactM[n]) % MOD);
}
signed main() {
  string x;
  ll l, r, n;
  cin >> x;
  n = x.length();
  for (ll i = 0; i < (n); i++) {
    if (x[i] == 'T') {
      l = i + 1;
      i = n;
    }
  }
  for (ll i = 0; i < (n); i++) {
    if (x[n - i - 1] == 'S') {
      r = i + 1;
      i = n;
    }
  }
  cout << n - ((l < r) ? (l) : (r)) * 2;
  return 0;
}
