#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int n = s.size();
  int sn = 0, tn = 0;
  for (int i = 0; i < n && s[i] == 'T'; i++) tn++;
  for (int i = n - 1; i >= 0 && s[i] == 'S'; i--) sn++;
  cout << tn + sn + abs(tn - sn) << endl;
  return 0;
}
