#include <bits/stdc++.h>
using namespace std;

int main() {
  string s; cin >> s;
  int n = 0;
  int m = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s.at(i) == 'T') {n--; m = min(m, n);}
    else {n++;}
  }
  cout << -2*m << endl;
}