#include <bits/stdc++.h>
using namespace std;
stack<char> s;
int main() {
  string a;
  cin >> a;
  int n = a.size();
  s.push(a[0]);
  for (int i = 1; i < n; i++) {
    char c = s.top();
    if (c == 'S' && a[i] == 'T')
      s.pop();
    else
      s.push(a[i]);
  }
  cout << s.size();
  return 0;
}
