#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
constexpr ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
int main() {
  string N;
  int n = 0;
  int nmax = 0;
  int ans = 0;
  cin >> N;
  for (int i = 0; i < N.size(); i++) {
    if (N[i] == 'S') {
      n++;
      if (n > nmax) {
        nmax = n;
      }
    } else {
      n--;
    }
  }
  cout << n * 2 << endl;
  return 0;
}
