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