#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;

const int mnx = 3e5 + 9;
const int mod = 1e9 + 7;

string x;
ll cnt;

int main(){

cin >> x;
int ans = length(x), s = 0;
for(int i=0; i<x.size(); i++) {
    if (x[i] == 'S') s++;
    else {
        if(s > 0) {
            ans -= 2;
            s--;
        }
    }
}
cout << ans;

return 0;

}













