#include <bits/stdc++.h>
using namespace std;
long long ans;
int main() {
  ios::sync_with_stdio(false);
  string a;
  char b[2] = {'S', 'T'};
  getline(cin, a);
  while (a.find(b) != string::npos) a.erase(a.find(b), 2);
  ans = a.length();
  printf("%d", ans);
  return 0;
}
