#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
int flg = 0;
string manu(string s, string t) {
  for (int i = 1; i < s.size(); ++i)
    if (s[i] == 'T' && s[i - 1] == 'S') {
      s[i] = 'a';
      s[i - 1] = 'a';
    }
  for (int i = 0; i < s.size(); ++i)
    if (s[i] != 'a')
      t += s[i];
    else
      flg = 1;
  return t;
}
int main() {
  string s, t;
  cin >> s;
  while (1) {
    flg = 0;
    t = manu(s, t);
    s = "";
    if (flg == 0) break;
    s = manu(t, s);
    t = "";
    if (flg == 0) break;
  }
  if (s.size() > t.size())
    cout << s.size() << endl;
  else
    cout << t.size() << endl;
}
