#include <bits/stdc++.h>
using namespace std;
char a[1000001];
bool used[1000000];
bool flag = 1;
int main() {
  cin >> a;
  int len = strlen(a);
  while (flag == 1) {
    flag = 0;
    for (int i = 0; i < len; i++) {
      if (a[i] == 'S' && a[i + 1] == 'T') {
        flag = 1;
        for (int j = i; j < len - 2; j++) {
          a[j] = a[j + 2];
        }
        len = len - 2;
      }
    }
    if (flag == 0) break;
  }
  cout << len << endl;
  return 0;
}
