#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
const int inf = 1e9;
const int mod = 1e9 + 7;
const double EPS = (double)1e-9;
const double pi = acos(-1.0);
const int MAXN = 1e5 + 5;
string s;
int main() {
  cin >> s;
  int res = 0;
  bool b = 1;
  while (b) {
    b = 0;
    if (s.empty()) break;
    for (int i = 0; i < (int)s.size() - 1; i++) {
      if (s[i] == 'S' && s[i + 1] == 'T') {
        s.erase(s.begin() + i, s.begin() + i + 2);
        b = 1;
        break;
      }
    }
  }
  cout << (int)s.size();
  return 0;
}
