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