#include <bits/stdc++.h>
using namespace std;
string s1, s2;
int main(int argc, char** argv) {
  s2.push_back('S');
  s2.push_back('T');
  cin >> s1;
  int p = s1.length();
  int ans = p;
  int l = 0;
  int r = 1;
  while (r < p) {
    if (s1[l] == 'S' && s1[r] == 'T') {
      ans = ans - 2;
      s1[l] = 0;
      s1[r] = 0;
      if (l != 0) {
        r++;
        l = r - 1;
      } else {
        r++;
        l = r - 1;
      }
    } else {
      r++;
      l = r - 1;
    }
  }
  cout << ans << endl;
  return 0;
}
