#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5;
string str;
int main() {
  getline(cin, str);
  int n = str.size();
  int m, flag = 0, sum = 0;
  while (flag == 0) {
    m = str.find("ST");
    if (m < 0)
      flag = 1;
    else {
      str.erase(m, 2);
      sum++;
    }
  }
  printf("%d\n", n - sum * 2);
  return 0;
}
