#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = (0); i < (n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define DEBUG(val) cout << #val << " : " << val << endl
#define MOD 1000000007

int main() {
  string str;
  cin >> str;
  int s = 0;
  int t = 0;
  int remove_count = 0;
  REP(i, str.length()) {
    if (str[i] == 'S') {
      s++;
    } else {
      if (s > 0) {
        s--;
        remove_count += 2;
      }
    }
  }
  cout << str.length() - remove_count << endl;
}
# include <iostream>
# include <deque>
using namespace std;

string X;
deque<char> dchar;

int main()
{
    cin>>X;

    for (int i=0; i<X.size(); i++)
    {
        dchar.push_back(X[i]);

        if (dchar.size()>=2 && dchar[dchar.size()-2]=='S' && dchar[dchar.size()-1]=='T')
        {
            dchar.pop_back();
            dchar.pop_back();
        }
    }

    cout<<dchar.size()<<endl;
}