#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 100;
string s;
int main() {
  ios_base::sync_with_stdio(NULL);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> s;
  int ans = 0, key = 0;
  for (int i = 0; i < s.size(); ++i) {
    if (s[i] == 'S') {
      key++;
    } else {
      key--;
    }
    if (key < 0) {
      ans++;
    }
  }
  cout << ans + max(key, 0);
  return 0;
}
