#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 100;
string s;
int main() {
  ios_base::sync_with_stdio(NULL);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> s;
  while (1) {
    if (!s.size()) {
      break;
    }
    int ct = 0;
    for (int i = 0; i < s.size() - 1; ++i) {
      if (s[i] == 'S' && s[i + 1] == 'T') {
        ct++;
        s.erase(i - (ct - 1) * 2, 2);
        i = -1;
      }
    }
    if (!ct) {
      break;
    }
  }
  cout << s.size();
  return 0;
}
