#include <bits/stdc++.h>
using namespace std;
string s;
int sum, num;
int main() {
  cin >> s;
  int tmp = s.length();
  for (int i = 0; i < tmp; i++) {
    if (s[i] == 'S') sum++;
    if (sum && (s[i] == 'T')) {
      sum--;
      num += 2;
    }
  }
  printf("%d\n", tmp - num);
}
