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