#include <bits/stdc++.h>
using namespace std;
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
std::string ReplaceString(std::string String1, std::string String2,
                          std::string String3) {
  std::string::size_type Pos(String1.find(String2));
  while (Pos != std::string::npos) {
    String1.replace(Pos, String2.length(), String3);
    Pos = String1.find(String2, Pos + String3.length());
  }
  return String1;
}
template <class T>
using vec = std::vector<T>;
template <class T>
void print(const T &x) {
  cout << x << "\n";
}
const long long MOD = 1000000007, INF = 1061109567, INF2 = INF * INF;
const double EPS = 1e-10, PI = acos(-1.0);
const long long dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  string X;
  cin >> X;
  while (1) {
    long long prev = X.size();
    X = ReplaceString(X, "ST", "");
    if (prev == (long long)X.size()) {
      print(prev);
      return 0;
    }
  }
}
