#include <bits/stdc++.h>
using namespace std;
int main() {
  std::string s;
  int n;
  cin >> s;
  int s_size = s.size();
  for (int i = 0; i < s.size(); i++) {
    int s_count = 0, t_count = 0;
    for (; i < s.size() && s[i] == 'S'; i++) s_count++;
    for (; i < s.size() && s[i] == 'T'; i++) t_count++;
    i--;
    if ((s_count && t_count)) s_size -= std::min(s_count, t_count) * 2;
  }
  cout << s_size << endl;
}
