#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int,int> p_int;
typedef pair<ll,ll> p_ll;
typedef tuple<ll,ll,ll> t3_ll;
int dx[] = {-1,0,1,0},dy[] = {0,1,0,-1};
int prime[] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97};
const ll inf = 1e9+7;

int main() {
	string s;
	cin  >> s;
	ll stack=0;ll syokyo=0;
	for (int i = 0;i < s.size();i++) {
		if (s[i] == "S") {stack++;}
		else if (stack > 0) {stack--;syokyo++;}
	}
	cout << s.size() - syokyo*2 << endl;
}