#include <iostream>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <stdio.h>
#include <cmath>
#include <sstream>
#include <algorithm>
#include <iomanip>

#define ll long long
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define vi vector<int>
#define vl vector<long long>
#define sz size()
#define x first
#define y second
#define pii pair<int, int>
#define pll pair<ll, ll>


using namespace std;
stack<char> st;
string s;

int main() {
	//freopen("", "r", stdin);                
	//freopen("", "w", stdout);
	cin >> s;
	
	for(int i = 0; i < s.sz; i++) {
		if(s[i] == 'S') st.push(s[i]);
		else {
			if(!st.empty() && st.top() == 'S') st.pop();
			else	st.push(s[i]);
		}
	}
	if(!st.empty()) cout << st.sz;
	else cout << 0;
	return 0;
}