#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  auto len = s.size(), ans = len;
  int lowerBound = 0, l = 0, r = 1;
  while (r < len) {
    if (s[l] == 'S' && s[r] == 'T') {
      ans = ans - 2;
      r++;
      if (l == lowerBound) {
        l = r;
        lowerBound = l;
        r++;
      }
    } else {
      l++, r++;
    }
  }
  cout << ans << endl;
  return 0;
}
