#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
bool coY() { cout << "Yes" << endl; }
bool coN() { cout << "No" << endl; }
const ll INF = 1LL << 60;
ll n, m;
string s;
const int mod = 1e9 + 7;
int main() {
  cin >> s;
  int countT = 0;
  n = s.size();
  for (int i = (0); i < (n); ++i) {
    if (s[i] == 'T') {
      countT++;
    } else {
      break;
    }
  }
  int countS = 0;
  reverse((s).begin(), (s).end());
  for (int i = (0); i < (n); ++i) {
    if (s[i] == 'S') {
      countS++;
    } else {
      break;
    }
  }
  int ans = max(countT, countS);
  cout << ans * 2 << endl;
}
