#include <bits/stdc++.h>
using namespace std;
const long long M = 1e7 + 9;
const long long inf = 1e19;
const int si = 1e5 + 9;
int a[200200];
int t;
int main() {
  string s;
  cin >> s;
  int cs = 0, ct = 0, ans = 0;
  for (int i = 0; i < int(int(s.size())); i++) {
    if (s[i] == 'S') cs++;
    if (s[i] == 'T') ct++;
    if (ct && cs) {
      ans++;
      ct--;
      cs--;
    }
  }
  cout << int(s.size()) - 2 * ans;
  return 0;
  ;
}
