#include <bits/stdc++.h>
using namespace std;
const int N = 200010;
char a[N];
int n, k, s, t, ans;
int main() {
  scanf("%s", a + 1);
  n = strlen(a + 1);
  k = 1;
  while (k <= n) {
    if (a[k] != a[k - 1]) {
      if (a[k] == 'S') {
        ans += s >= t ? 0 : t - s;
        if (s >= t)
          s -= t, t = 0;
        else
          s = 0, t = 0;
        s++;
      } else
        t++;
    } else {
      if (a[k] == 'S')
        s++;
      else
        t++;
    }
    k++;
  }
  if (a[n] == 'S')
    ans += s;
  else
    ans += s >= t ? 0 : t - s;
  cout << ans << endl;
  return 0;
}
