#include <iostream>
using namespace std;

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

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


	void push(char value){
		Node *node=new Node(value);
		node->next=top;
		top=node;
	}

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

	void Stst(){
		Node *node = top;
		int cnt = 0;
		while(node->next != NULL){
			while(node->value != 'S'){
				node = node->next;
				cnt++;
			}
			if(node->value == 'S'){
				cnt++;
			}
			if(node->next->value == 'T'){
				while(cnt != 0){
					pop();
					cnt--;
				}
			}
			node = node->next;
		}
	}

	int countt(){
		Node *node = top;
		int cnt = 0;
		while(node != NULL){
			node = node->next;
			cnt++;
		}
		return cnt;
	}
};
int main() {
	Stack *s = new Stack();
	s->push('S');
	s->push('S');
	s->push('T');
	s->push('T');
	s->push('S');
	s->push('T');
	s->Stst();
	cout<<s->countt();
	return 0;
}