#include <string>
#include <iostream>                                                                                                                                                                                                                                                         int main() {                                                                                                                            std::string X;
  std::cin >> X;
  int n = X.length();
  int ans = n;
  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    if (X[i] == 'S') ++cnt;
    else {
      if (cnt > 0) {
        --cnt;
        ans -= 2;
      }
    }
  }
  std::cout << ans << std::endl;
}                                                                                                                                     