#include <bits/stdc++.h>
using namespace std;
int main() {
  char a[100000];
  vector<char> v;
  cin >> a;
  int i, s = strlen(a);
  for (i = 0; i < strlen(a); i++) v.push_back(a[i]);
  i = 0;
  while (1) {
    if (v[i] == 'S' && v[i + 1] == 'T') {
      v.erase(v.begin() + i);
      v.erase(v.begin() + i);
      if (i == 0) i++;
      i -= 2;
    }
    if (i + 1 == v.size()) break;
    i++;
  }
  cout << v.size() << endl;
  return 0;
}
