#include <bits/stdc++.h>
using namespace std;
long long INF = 1000000000000000000;
long long mod = 1000000007;
using namespace std;
int main() {
  string s;
  cin >> s;
  long long x = s.size();
  long long t_cnt = 0;
  for (long long i = 0; i < s.size(); i++) {
    if (s[i] == 'S' && t_cnt < s.size() / 2) {
      x -= 2;
    } else if (s[i] == 'T') {
      t_cnt++;
    }
  }
  cout << x << endl;
  return 0;
}
