#include <iostream>
#include <cstdio>
using namespace std;

int c, ans;
string a;
int main()
{
	int i;
	cin >> a;
	for (i = 0; i < a.size(); i++) {
		if (a[i] == 'S') c++;
		else ans += (c == 0), c = max(0, c - 1);
	}
    cout << c + ans << endl;
    return 0;
}