#include <iostream>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
 
using namespace std;
 
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long
#define pii pair < int, int >
#define pll pair < long long, long long>
#define ull unsigned long long
#define vi vector <int>
#define sz(a) (int)a.size()
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++)
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x))
#define fname "repetition"
 
const int inf = (int)1e9;
const ll INF = (ll)1e18;
const double eps = 1e-9;
const double pi = acos(-1.0);

string s;
stack<char> q;

int main(){
	// freopen("input.txt", "r", stdin);
	cin >> s;
	for(int i = 0; i < sz(s); ++i){
		if(q.empty())
			q.push(s[i]);
		else{
			if(s[i] == 'S'){
				q.push(s[i]);
			}else{
				if(q.top() == 'S')
					q.pop();
				else
					q.push(s[i]);
			}
		}
	}
	printf("%d\n", (int)sz(q));
	return 0;
}