#include <iostream>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <deque>
#include <queue>
#include <numeric>
#include <cctype>
#include <sstream>

using namespace std;

#define __ ios_base::sync_with_stdio(0);cin.tie(0);
#define pb push_back
#define mp make_pair
#define sz(a) (int)(a.size())
#define sqr(a,b) pow(a, b*1.0)
#define all(a) a.begin(), a.end()
#define ff first
#define ss second
#define ll long long
#define pii pair <int, int>
#define pll pair <ll, ll>
#define vi vector <int>
#define vll vector <ll>
#define vpi vector <pii>
#define vpl vector <pll>
#define sc1(a) scanf("%d", &a)
#define sc2(a, b) scanf("%d%d", &a, &b)
#define frw(i, p, n) for(int i = p; i <= n; i++)
#define bck(i, n, p) for(int i = n; i >= p; i--)
#define mem(a) memset(a, 0, sizeof(a))

int main(){ __
	stack<char> st;
	char x;
	while(cin>>x){
		if(st.size()>0){
			char z=st.top();
			if(x=='T' && z=='S'){
				st.pop();
			}else{
				st.push(x);
			}	
		}else{
			st.push(x);
		}
	}
		cout<<st.size();
return 0;
}	
			    