#include <bits/stdc++.h>
using namespace std;
int main() {
  string str;
  cin >> str;
  bool foundmatches = false;
  for (long long iteration = 0; iteration < pow(10, 10000); iteration++) {
    int begin_index = 0;
    foundmatches = false;
    int size = str.size() - 1;
    for (int i = 0; i < size; i++) {
      if (str[i] == 'S' && str[i + 1] == 'T') {
        begin_index = i;
        foundmatches = true;
        break;
      }
    }
    if (foundmatches)
      str.erase(str.begin() + begin_index, str.begin() + begin_index + 2);
    else
      break;
  }
  cout << str.size() << endl;
}
