#include <bits/stdc++.h>
using namespace std;
int main() {
  string str;
  cin >> str;
  int i = 0, j = 1;
  int w = 0;
  int cnt = 0;
  int l = str.length();
  while (j < l) {
    if (str[i] == 'S' && str[j] == 'T') {
      i--;
      j++;
      cnt++;
      if (i < w) {
        i = j;
        j = i + 1;
        w = i;
      }
    } else {
      i = j;
      j = i + 1;
    }
  }
  cout << l - cnt * 2 << endl;
  return 0;
}
