#include <bits/stdc++.h>
using namespace std;
int main() {
  char c[100005];
  scanf("%s", c);
  int ans = 0;
  int sum = 0;
  for (int i = 0; c[i] != 0; i++) {
    if (c[i] == 'S')
      sum++;
    else {
      if (sum)
        sum--;
      else
        ans++;
    }
  }
  printf("%d\n", ans + sum);
}
