#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
char c[maxn];
int tot, ans;
int main() {
  char a;
  while (scanf("%c", &a) != EOF) {
    c[tot++] = a;
  }
  ans = tot - 1;
  int i = 0, j = 1;
  while (j < tot) {
    if (c[i] == 'S' && c[j] == 'T') {
      ans -= 2;
      i--;
      j++;
    } else {
      i = j;
      j++;
    }
  }
  cout << ans << endl;
  return 0;
}
