import std.stdio;
import std.conv, std.array, std.algorithm, std.string;
import std.math, std.random, std.range, std.datetime;
import std.bigint;

void main(){
	string s = readln.chomp;
	
	int scount;
	int tcount;
	foreach(c; s){
		if(c == 'S') scount += 1;
		else{
			if(scount > 0) scount -= 1;
			else tcount += 1;
			}
		}
	
	int ans = tcount * 2;
	ans.writeln;
	
	}
