#include <bits/stdc++.h>
using namespace std;
int chh;
const int N = 200005;
int n;
string s;
int main() {
  int ans, l, r;
  while (cin >> s) {
    n = (s).size(), ans = n;
    l = 0, r = 1;
    while (r < n) {
      if (!(s[l] == 'S' && s[r] == 'T'))
        l = r, r++;
      else {
        l--, r++;
        ans -= 2;
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}
