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