#include <bits/stdc++.h>
using namespace std;
string s;
long long length, ans;
void dfs() {
  length = s.length();
  if (length <= 1) return;
  for (int i = 0; i < length; i++) {
    if (i == length - 1) return;
    if (s[i] == 'S' && s[i + 1] == 'T') {
      s.erase(i, 2);
      break;
    }
  }
  dfs();
}
int main() {
  cin >> s;
  dfs();
  printf("%d\n", length);
  return 0;
}
