#include <bits/stdc++.h>
using namespace std;
string s;
int main() {
  cin >> s;
  int snum = 0, tnum = 0;
  int ans = s.size();
  int i = 0;
  while (i < s.size()) {
    snum = tnum = 0;
    if (s[i] == 'S') {
      while (s[i] == 'S') {
        snum++;
        i++;
      }
      while (s[i] == 'T') {
        tnum++;
        i++;
      }
      ans -= min(snum, tnum) * 2;
    }
    i++;
  }
  cout << ans;
  return 0;
}
