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