#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int size = s.size();
  vector<char> v;
  int cnt = size;
  for (int i = 0; i < size; i++) {
    v.push_back(s[i]);
  }
  for (int i = 0; i < size; i++) {
    if (v[i] == 'S' && v[i + 1] == 'T') {
      cnt -= 2;
      v.erase(v.begin() + i, v.begin() + i + 1);
      i -= 2;
    }
  }
  cout << cnt << endl;
  return 0;
}
