#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  auto first = s.find_first_of('S');
  auto last = s.find_last_of('T');
  int count_s = 0;
  int count_t = 0;
  for (auto i = first; i <= last; ++i) {
    if (s[i] == 'S') ++count_s;
    if (s[i] == 'T') ++count_t;
  }
  int count = count_s < count_t ? count_s : count_t;
  cout << (s.size() - count * 2) << endl;
  return 0;
}
