#include <bits/stdc++.h>
using namespace std;
int main() {
  string x;
  int N = x.length();
  int m = 0;
  int t = 0;
  int s = 0;
  for (int i = 0; i < N; i++) {
    if (x[i] == 'S') {
      s++;
    } else if (s > 0) {
      s--;
    } else {
      t++;
      m = max(m, t);
    }
  }
  cout << m * 2 << endl;
  return 0;
}
