#include <bits/stdc++.h>
using namespace std;

string s;
int sol, ans;

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    cin >> s;
    sol = 0, ans = 0;
    for(int i = 0; i < s.size(); i++) {
        if(s[i] == 'S') sol++;
        else {
            if(sol > 0) sol--;
            else ans++;
        }
    }
    cout << ans + sol << "\n";
}
#include<iostream>
#include<cstdio>
#include<string>
using namespace std;
int main()
{
	string a;
	cin>>a;
	int tmp=a.find("ST");
	while(a.length()>0&&tmp>=0)
	{
		a.erase(tmp,2);
		int x=max(tmp-1,0);
		tmp=a.find("ST",x);
		if(tmp==string::npos)
			tmp=-1;
	}
	cout<<a.length()<<endl;
	return 0;
} 