#include <bits/stdc++.h>
using namespace std;
const int N = 1234567;
char s[N], st[N];
int main() {
  gets(s);
  int n = strlen(s);
  int e = 0;
  for (int i = 0; i < n; i++) {
    if (e > 0 && st[e - 1] == 'S' && s[i] == 'T') {
      e--;
    } else {
      st[e++] = s[i];
    }
  }
  printf("%d\n", e);
  return 0;
}
