#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200005;
char s[MAXN];
int n, sum, ans;
int main() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  for (int i = 1; i <= n; ++i) sum += s[i] == 'S' ? 1 : -1, ans += (sum < 0);
  cout << ans << endl;
  return 0;
}
