#include <bits/stdc++.h>
namespace tools {
template <typename T>
void read(std::vector<T>& vector,
          const typename std::vector<T>::size_type size) {
  vector.reserve(size);
  std::copy_n(std::istream_iterator<T>(std::cin), size,
              std::back_inserter(vector));
}
template <typename T, std::size_t N>
void read(std::array<T, N>& array) {
  std::copy_n(std::istream_iterator<T>(std::cin), N, array.begin());
}
}  // namespace tools
int main() {
  std::string X;
  std::cin >> X;
  const std::int_fast64_t N = X.size();
  std::int_fast64_t answer = N;
  for (std::int_fast64_t i = 0; i < N - 1; ++i) {
    std::int_fast64_t j, k;
    for (j = i, k = i + 1; j >= 0 && k < N && X[j] == 'S' && X[k] == 'T';
         --j, ++k)
      ;
    answer -= k - j - 1;
  }
  std::cout << answer << std::endl;
  return 0;
}
