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