#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using pint = pair<int, int>;
const int INF = (1 << 30);
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  bool f;
  while (true) {
    f = false;
    if (s.size() == 0) break;
    for (int i = 0; i < s.size() - 1; ++i) {
      if (s[i] == 'S' && s[i + 1] == 'T') {
        s.erase(s.begin() + i, s.begin() + i + 2);
        f = true;
        break;
      }
    }
    if (!f) break;
  }
  cout << s.size() << endl;
  return 0;
}
