#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long double PI = acos(-1);
const long double EPS = 0.0000000001;
int main() {
  string s;
  cin >> s;
  int ans = s.size(), tc = 0, sc = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'S')
      sc += 1;
    else {
      tc += 1;
      int x = min(sc, tc);
      ans -= 2 * x;
      sc -= x;
      tc -= x;
    }
  }
  cout << ans << endl;
}
