#include <bits/stdc++.h>
using namespace std;
int main() {
  string str;
  cin >> str;
  int count = 0;
  while (1) {
    int i = str.find("ST");
    if (i == string::npos) break;
    int j = 0;
    while (i - j >= 0 && i + j + 1 < str.size() && str[i - j] == 'S' &&
           str[i + 1 + j] == 'T') {
      count += 2;
      str[i - j] = ' ';
      str[i + j + 1] = ' ';
      j++;
    }
  }
  cout << str.size() - count << endl;
  return 0;
}
