#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007LL;
int main() {
  string X;
  cin >> X;
  int S = 0;
  int T = 0;
  int cnt = 0;
  for (int i = 0; i < X.size(); i++) {
    if (X[i] == 'S') {
      if (T == 0) {
        S++;
      } else {
        cnt += min(S, T) * 2;
        S = 1;
        T = 0;
      }
    } else {
      if (S > 0) T++;
    }
  }
  cnt += min(S, T) * 2;
  cout << X.size() - cnt << endl;
}
