#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int f = 0;
  for (int i = 0; i < 100000; i++) {
    for (int j = 0; j < s.size() - 1; j++) {
      if (s[j] == 'S' and s[j + 1] == 'T') {
        s.erase(s.begin() + j);
        s.erase(s.begin() + j);
        f = 1;
        if (s.size() < 2) f = 0;
        break;
      }
    }
    if (f == 0) break;
  }
  cout << s.size() << endl;
  return 0;
}
