#include <bits/stdc++.h>
using namespace std;
int f[200005];
void failure_function(string p) {
  int l = p.length();
  memset(f, 0, sizeof(f));
  int j = 0, i;
  for (i = 1; i < l; i++) {
    while (j >= 0 && p[j] != p[i]) {
      if ((j - 1) >= 0)
        j = f[j - 1];
      else
        j = -1;
    }
    j += 1;
    f[i] = j;
  }
}
int vis[200005];
string find_occurences(string t, string p) {
  int i;
  string s = "";
  failure_function(p);
  int lt = t.length();
  int lp = p.length();
  int j = 0;
  memset(vis, 0, sizeof(vis));
  for (i = 0; i < lt; i++) {
    while (j >= 0 && t[i] != p[j]) {
      if ((j - 1) >= 0)
        j = f[j - 1];
      else
        j = -1;
    }
    j += 1;
    if (j == lp) {
      j = f[lp - 1];
      vis[i - lp + 1] = vis[i - lp + 2] = 1;
    }
  }
  for (i = 0; i < t.length(); i++) {
    if (vis[i] == 0) s += t[i];
  }
  return s;
}
int main() {
  string s;
  cin >> s;
  while (s.length() > 0) {
    string news = find_occurences(s, "ST");
    if (news.length() == s.length())
      break;
    else
      s = news;
  }
  cout << s.length() << endl;
  return 0;
}
