#include <bits/stdc++.h>
using namespace std;
char s[200010];
int x, ans;
bool find() {
  for (int i = 0; i < x - 1; i++) {
    if (s[i] == 'S' && s[i + 1] == 'T') {
      for (int j = i + 2; j < x; j++) {
        s[j - 2] = s[j];
      }
      x = x - 2;
      return true;
    }
  }
  return false;
}
int main() {
  scanf("%s", &s);
  x = strlen(s);
  while (find()) {
  }
  cout << x << endl;
}
