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