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

class Node {
	public: char val;
	Node *next;
	Node(int val){
	this-> val = val;
	}
	
};

class Stack {
	public: int size;
			Node *top;
	Stack() {
		size = 0;
		top = NULL;
	}

	void push(char val) {
		Node *nd = new Node(val);
		nd->next =top;
		top= nd;
		size++;
	}

	void pop(){
		if(top != NULL){
			top=top->next;
			size--;
		}

	}

	int getsize(){
		return size;
	}

};
string X;
Stack *st = new Stack;

int main(){
	cin>>X;
	for(int i=0; i<X.length(); i++){
		st->push(X[i]);
		if(st[i] == "T" && st[i-1] == "S"){
			st->pop();
			st->pop();
		}
	}
	cout>>st->getsize();
}
