#include <bits/stdc++.h>
using namespace std;
int main() {
  string x;
  cin >> x;
  int sz = x.size(), s = 0, g = 1;
  for (int i = 0; i < x.size();) {
    if (x[i] == 'S') {
      s++;
      i++;
    }
    if (x[i] == 'T') {
      while (s) {
        g = 0;
        if (x[i] == 'T') {
          sz -= 2;
        } else {
          break;
        }
        s--;
        i++;
      }
    }
    if (g == 1 && s == 0) {
      i++;
    }
  }
  cout << sz;
}
