#include <bits/stdc++.h>
const long long INF = 1e18 + 1;
const long long MOD = 1e9 + 7;
void print() { std::cout << std::endl; }
template <typename Head>
void print(Head&& head) {
  std::cout << head << std::endl;
}
template <typename Head, typename... Tail>
void print(Head&& head, Tail&&... tail) {
  std::cout << head << " ";
  print(std::forward<Tail>(tail)...);
}
template <typename Iterator>
void printVec(Iterator begin, Iterator end) {
  for (Iterator it = begin; it != end; it++) {
    std::cout << "[" << std::distance(begin, it) << "] " << *it << " ";
    if (std::distance(begin, it) % 20 == 19) {
      std::cout << std::endl;
    }
  }
  std::cout << std::endl;
}
int main(int argc, char* argv[]) {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  std::string s;
  std::cin >> s;
  long long ans = (long long)s.size();
  while (1) {
    bool was_updated = false;
    for (long long i = 0; i < ans; ++i) {
      if (s[i] == 'S' && s[i + 1] == 'T') {
        was_updated = true;
        for (long long j = i + 2; j < ans; ++j) {
          s[j - 2] = s[j];
        }
        ans -= 2;
      }
    }
    if (!was_updated) {
      break;
    }
  }
  print(ans);
  return 0;
}
