#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
signed main() {
  string s;
  cin >> s;
  bool flag = true;
  while (flag) {
    flag = false;
    for (long long i = 0; i < (s.length() - 1); ++i) {
      if (s[i] == 'S' && s[i + 1] == 'T') {
        s.erase(i, 2);
        flag = true;
      }
    }
  }
  cout << (s.length()) << endl;
  ;
  return 0;
}
