#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
char ch[maxn];
int len, flag;
deque<char> Q;
int main() {
  cin >> ch;
  len = strlen(ch);
  Q.clear();
  Q.push_back(ch[0]);
  for (int i = 1; i < len; i++) {
    char u = Q.back();
    flag = 0;
    if (u == 'S' && ch[i] == 'T') {
      Q.pop_back();
      i++;
      flag = 1;
      if (Q.size()) u = Q.back();
    }
    if (u != 'S' || ch[i] != 'T') Q.push_back(ch[i]);
    if (flag == 1 && i != len - 1) i--;
  }
  int ans = Q.size();
  if (ans % 2 == 1) ans--;
  cout << ans << endl;
  return 0;
}
