#include <bits/stdc++.h>
using namespace std;
const long long INFL = 1e18;
const int INF = 1001001001;
const int mod = 1000000007;
int main() {
  string x;
  cin >> x;
  int s = 0, t = 0;
  bool f = true;
  if (x[0] == 'T') {
    f = false;
    t++;
  } else
    s++;
  int ans = x.length();
  for (int i = 0; i < (x.length()); i++) {
    if (i == 0) continue;
    if (f) {
      if (x[i] == 'T') {
        f = false;
        s--;
        ans -= 2;
      } else
        s++;
    } else {
      if (x[i] == 'S') {
        s = 1;
        f = true;
      } else {
        if (s != 0) {
          s--;
          ans -= 2;
        }
      }
    }
  }
  cout << ans << endl;
}
