#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  string s;
  cin >> s;
  int n = s.size();
  reverse(s.begin(), s.end());
  bool ok = false;
  int cnt = 0;
  for (int i = 0; i < (n); i++) {
    if (!ok && s[i] == 'T')
      ok = true;
    else if (ok && s[i] == 'S')
      cnt++;
  }
  int ans = n - cnt * 2;
  if (ans < 0) ans = 0;
  cout << ans << endl;
  return 0;
}
