#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int len = s.length();
  int ans = len;
  int count_s = 0;
  int count_t = 0;
  for (int i = 0; i < len; i++) {
    if (s[i] == 'T' && count_s == 0) continue;
    if (s[i] == 'S' && count_t == 0) {
      count_s++;
    }
    if (s[i] == 'T' && count_t < count_s) {
      count_t++;
    }
    if (count_s != 0 && count_s == count_t) {
      ans = ans - 2 * count_s;
      count_s = count_t = 0;
    }
  }
  cout << ans << endl;
  return 0;
}
