#include <bits/stdc++.h>
using namespace std;
char a[200010];
int main() {
  cin >> a;
  int ans, al = strlen(a);
  ans = al;
  for (int i = 0; i < al; i++) {
    if (a[i] == 'S' && a[i + 1] == 'T') {
      int l = i, r = i + 1;
      while (a[l] == 'S' && a[r] == 'T') ans -= 2, l -= 1, r += 1;
      i = r - 1;
    }
  }
  cout << ans << endl;
  return 0;
}
