#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  string x;
  cin >> x;
  ll l, ss = 0, tt = 0;
  l = x.size();
  string s;
  ll ans = 0;
  for (int i = 0; i < (l); ++i) {
    if (x[l - 1 - i] == 'S') {
      ++ss;
    } else {
      break;
      ++tt;
    }
    ans = max(ans, ss - tt);
  }
  cout << 2 * ans << endl;
  return 0;
}
