#include<iostream>
#include<stdio.h>
#include<vector>
using namespace std;
vector<char> v;
char x;
int main()
{
	while (scanf_s("%c", &x))
	{
		v.push_back(x);
	}
	int num = 0;
	for (vector<char>::iterator it = v.begin() + 1; it != v.end(); it++)
	{
		if (*(it - 1) == 'S' && *it == 'T')
		{
			v.erase(it - 1);
			v.erase(it);
			num++;
			it = v.begin() + 1;
		}
		if (num == 10 ^ 10000)break;
	}
		cout << v.size();
	return 0;
}