#include <bits/stdc++.h>
using namespace std;
const int max4 = 10004;
const int maxx = 100005;
const int max6 = 1000006;
const int lg5 = 17;
const int INF = 2 * 1000000007;
const long long INFLL = 4LL * 1000000000 * 1000000000;
int powmod(int a, int b, int mod) {
  int res = 1;
  a %= mod;
  for (; b; b >>= 1) {
    if (b & 1) {
      res = 1LL * res * a % mod;
    }
    a = 1LL * a * a % mod;
  }
  return res;
}
long long gcd(long long a, long long b) {
  while (b > 0) {
    long long t = a % b;
    a = b, b = t;
  }
  return a;
}
int lcm(int a, int b) { return (a / gcd(a, b)) * b; }
int is_prime(int n) {
  if (n <= 1 || n > 3 && (n % 2 == 0 || n % 3 == 0)) return 0;
  for (int i = 5, t = 2; i * i <= n; i += t, t = 6 - t)
    if (n % i == 0) return 0;
  return 1;
}
int main() {
  ios_base ::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  string s;
  cin >> s;
  int n = s.size(), res = n;
  for (int i = 0, cnt = 0; i < n;) {
    if (s[i] == 'S') {
      while (i < n && s[i] == 'S') {
        cnt++;
        i++;
      }
    } else {
      int cntt = 0;
      while (i < n && s[i] == 'T') {
        cntt++, i++;
      }
      res -= 2 * min(cntt, cnt);
      cnt = 0;
    }
  }
  cout << res << '\n';
  return 0;
}
