#include <bits/stdc++.h>
using namespace std;
const int maxn = 200000 + 5;
const int mod = 10007;
const double PI = acos(-1.0);
const double eps = 1e-10;
char s[maxn];
int main() {
  while (~scanf("%s", s)) {
    int ans = strlen(s);
    int ns = 0, nt = 0;
    for (int i = 0; s[i]; i++) {
      if (s[i] == 'S') {
        if (nt) {
          ans -= min(ns, nt) * 2;
          nt = ns = 0;
        }
        ns++;
      } else {
        nt++;
      }
    }
    if (nt) {
      ans -= min(nt, ns) * 2;
    }
    printf("%d\n", ans);
  }
  return 0;
}
