#include <bits/stdc++.h>
using namespace std;
int main() {
  string str;
  std::cin >> str;
  int n = str.size();
  int i = 0;
  int st = 0;
  while (i < n) {
    if (str[i] == 'T') {
      i++;
      continue;
    }
    int s = 0;
    while (str[i] == 'S') {
      s++;
      i++;
    }
    while (str[i] == 'T' && s > 0) {
      s--;
      st++;
      i++;
    }
  }
  std::cout << n - st * 2 << std::endl;
}
