#include <bits/stdc++.h>
using namespace std;
long long const INF = 9e9;
int main() {
  string S;
  cin >> S;
  int s = 0, t = 0;
  int ans = 0;
  for (int i = 0; i < S.size(); i++) {
    if (S.at(i) == 'S') {
      if (s != 0 && t != 0) {
        ans += min(s, t);
        s = 0;
        t = 0;
      }
      s++;
    } else {
      t++;
    }
  }
  if (s != 0 && t != 0) {
    ans += min(s, t);
    s = 0;
    t = 0;
  }
  cout << S.size() - ans * 2 << endl;
}
