#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int n = s.size();
  int is, it, ts = 0, tt = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'S') {
      is = i;
      break;
    }
  }
  for (int i = n - 1; i >= 0; i--) {
    if (s[i] == 'T') {
      it = i;
      break;
    }
  }
  for (int i = is; i <= it; i++) {
    if (s[i] == 'S') {
      ts += 1;
    }
    if (s[i] == 'T') {
      tt += 1;
    }
  }
  n -= 2 * min(tt, ts);
  cout << n << endl;
  return 0;
}
