#include<bits/stdc++.h>
using namespace std;
int n, x, ans;
char a[200005];

int main()
{
	scanf("%s",a+1);
	n = strlen(a+1);
	for(int i=1;i<=n;i++) {
		if(a[i] == 'T') if(x) {x--; ans++;}
		if(a[i] == 'S') x++;
	}
	printf("%d\n",n-2*ans);
}
