#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T>
void view(const std::vector<T> &v) {
  for (const auto &e : v) {
    std::cout << e << " ";
  }
  std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv) {
  for (const auto &v : vv) {
    view(v);
  }
}
int main() {
  string s;
  cin >> s;
  bool st = true;
  int i = 1;
  bool nowst = false;
  while (st && s.size()) {
    if (s.at(i - 1) == 'S' && s.at(i) == 'T') {
      s = s.substr(0, i - 1) + s.substr(i + 1);
      nowst = true;
    }
    if (++i >= s.size()) {
      st = nowst;
      nowst = false;
      i = 1;
    }
  }
  cout << s.size() << endl;
  return 0;
}
