#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;
int main() {
  string x;
  cin >> x;
  ll temp = 0;
  ll ans = 0;
  for (int i = (int)(0); i < (int)(x.size()); ++i) {
    while (i < x.size() && x[i] == 'S') {
      temp++;
      i++;
    }
    while (i < x.size() && x[i] == 'T' && temp) {
      temp--;
      i++;
      ans++;
    }
  }
  int n = x.size();
  cout << n - 2 * ans << endl;
  return 0;
}
