#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  string s;
  cin >> s;
  int ans = s.size();
  int prevpos = -1;
  for (int i = 0; i < s.size() - 1; i++) {
    if (s[i] == 'S' && s[i + 1] == 'T') {
      ans = ans - 2;
      int nextpos = i + 2;
      while (prevpos >= 0 && nextpos < s.size()) {
        if (s[prevpos] == 'S' && s[nextpos] == 'T') {
          ans = ans - 2;
          prevpos--;
          nextpos++;
        } else {
          break;
        }
      }
      i = nextpos - 1;
    } else {
      prevpos = i;
    }
  }
  cout << ans << endl;
}
