#include <bits/stdc++.h>
using namespace std;
bool solve(int i, int m);
int main() {
  int scount = 0;
  int tcount = 0;
  string s;
  cin >> s;
  int ss = s.size();
  int ans = ss;
  for (int i = 0; i < ss; i++) {
    if (s[i] == 'T') {
      tcount++;
      while (tcount > 0 && scount > 0) {
        ans -= 2;
        tcount--;
        scount--;
      }
    }
    if (s[i] == 'S') scount++;
  }
  cout << ans << endl;
}
