#include <bits/stdc++.h>
using namespace std;
int N;
vector<int> a;
char s[100010];
int main() {
  scanf("%s", s);
  N = strlen(s);
  for (int i = 0; i < N; i++) {
    if (s[i] == 'S')
      a.push_back(0);
    else {
      if (a.size() != 0 && a.back() == 0) {
        a.pop_back();
      } else
        a.push_back(1);
    }
  }
  printf("%d\n", a.size());
  return 0;
}
