#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
void cmax(T& a, U b) {
  if (a < b) a = b;
}
template <class T, class U>
void cmin(T& a, U b) {
  if (a > b) a = b;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int n = s.size();
  int s_pos = s.find("S");
  int t_pos = s.rfind("T");
  cerr << n << endl;
  cerr << s_pos << endl;
  cerr << t_pos << endl;
  int s_cnt = 0;
  int t_cnt = 0;
  for (long long i = 0; i < t_pos - s_pos + 1; i++) {
    if (s[i + s_pos] == 'S')
      s_cnt++;
    else
      t_cnt++;
  }
  cerr << s_cnt << endl;
  cerr << t_cnt << endl;
  cout << s_pos + abs(s_cnt - t_cnt) + n - t_pos - 1 << endl;
}
