#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, j, ans = 0, n;
  string s;
  cin >> s;
  n = s.length();
  ans = n;
  int l = 0;
  for (i = 0; i < n; ++i) {
    if (s[i] == 'S')
      l++;
    else {
      j = i;
      int r = 0;
      while (s[j] == 'T') j++, r++;
      i = j - 1;
      ans -= 2 * min(l, r);
      l = 0;
    }
  }
  cout << ans;
  return 0;
}
