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