#include <bits/stdc++.h>
using namespace std;
signed main() {
  string second;
  cin >> second;
  long long int i = 0;
  while (i < second.size()) {
    while (i < second.size() - 1 && second[i] == 'S' && second[i] == 'T') i++;
    if (i < second.size() - 1)
      second =
          second.substr(0, i) + second.substr(i + 2, second.size() - i - 2);
    else
      break;
    i = 0;
  }
  cout << second.size() << endl;
  return 0;
}
