import std.stdio, std.string, std.conv;
import std.algorithm, std.array;
auto solve(string X) {
    immutable N = X.length.to!int();
    int n=0,q=0;
    foreach(c;X) {
        if(c=='S') ++q;
        else if(q>0) --q;
        else ++n;
    }
    return n+q;
}
void main(){ for(string s; (s=readln.chomp()).length;) writeln(solve(s)); }