#include <bits/stdc++.h>
using namespace std;
int i, j, s;
char a[10000], b;
int main() {
  while ((b = getchar()) != '\n') {
    s++;
    if (b == 'S') a[i++] = b;
    if (b == 'T') a[i++] = b;
    if (a[i - 2] == 'S' && a[i - 1] == 'T') {
      s -= 2;
      i -= 2;
    }
  }
  cout << s;
  return 0;
}
