#include <bits/stdc++.h>
using namespace std;
int solve(string str) {
  int pos = 0;
  while ((pos = str.find("ST")) != -1) str.erase(pos, 2);
  return str.length();
}
int main() {
  string str;
  cin >> str;
  cout << solve(str);
}
