#include <bits/stdc++.h>
using namespace std;
char s[200010];
int l, T;
int main() {
  scanf("%s", s);
  while (s[++l])
    ;
  int i = 0;
  while (1) {
    if (s[i++] == 'S') {
      T--;
      l -= 2;
    } else
      T++;
    if (T == l / 2) break;
  }
  printf("%d\n", T * 2);
  return 0;
}
