#include <bits/stdc++.h>
using namespace std;
const long long inf = INT_MAX;
int main(void) {
  string s;
  cin >> s;
  vector<bool> check(s.size(), false);
  int ans = s.size();
  for (int i = 0; i < (s.size()); i++) {
    if (s[i] == 'S') {
      check[i] = true;
      for (int j = i + 1; j < (s.size()); j++) {
        if (s[j] == 'T' && !check[j]) {
          check[j] = true;
          ans -= 2;
          break;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}
