#include <bits/stdc++.h>
int main(void) {
  char x[200001];
  int l, ct = 0, cs = 0, ans = 0;
  std::cin >> x;
  l = std::strlen(x);
  while (x[ct] == 'T') ct++;
  for (int i = ct; i != l; i++) {
    if (x[i] == 'S') {
      cs++;
    } else {
      if (cs > 0)
        cs--;
      else
        ans++;
    }
  }
  std::cout << ct + ans + cs << std::endl;
  return 0;
}
