#include <bits/stdc++.h>
using namespace std;
signed main(void) {
  string s;
  cin >> s;
  int n, start, goal, cnt_s, cnt_t;
  n = s.size();
  for (int i = n - 1; i >= 0; i--) {
    if (s[i] == 'T') {
      goal = i;
      break;
    }
  }
  for (int i = 0; i < (n); i++) {
    if (s[i] == 'S') {
      start = i;
      break;
    }
  }
  cnt_s = cnt_t = 0;
  for (int i = start; i <= goal; i++) {
    if (s[i] == 'S') {
      cnt_s++;
    } else
      cnt_t++;
  }
  int ans = n - 2 * min(cnt_s, cnt_t);
  cout << ans << endl;
  return 0;
}
