/* ADS2016 FINAL CONTEST :) */
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <cmath>
#include <string>
#include <cstdio>
#define pb push_back
#define mk make_pair

using namespace std;

int main () {

	// freopen("fileName.in", "r", stdin);
	// freopen("fileName.out", "w", stdout);

	stack <char> st;

	string s;
	cin >> s;

	for(int i = 0; i < s.length(); i++){
		if(st.empty() || !(st.top() == 'S' && s[i] == 'T'))
			st.push(s[i]);
		else
			st.pop();
	}

	cout << st.size() << endl;
}