#include <bits/stdc++.h>
using namespace std;
void judge(string& s) {
  int mark = 0;
  string::size_type s_t;
  string t = "ST";
  while ((s_t = s.find(t, 0)) != string::npos) {
    s.erase(s_t, t.length());
    break;
  }
  if (mark == 0) return;
  judge(s);
}
int main() {
  string s = "";
  cin >> s;
  judge(s);
  cout << s.size() << endl;
  return 0;
}
