#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const long long LINF = 1e18;
const double EPS = 1e-9;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int cntt = 0;
  int cnts = 0;
  int n = (int)s.size();
  int ans = n;
  for (int(i) = 0; (i) < (int)(n); i++) {
    if (s.at(i) == 'S') {
      cnts++;
    } else {
      cntt++;
      if (cntt <= cnts && cnts > 0) {
        cntt--;
        cnts = max(cnts - 1, 0);
        ans -= 2;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
