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