#include <bits/stdc++.h>
using namespace std;
int main() {
string s;
cin >> s;
int cnt = 0, ans = 0;
for (int i = 0; i < (int)s.size(); ++i) {
if (s[i] == 'S') ++cnt;
else {
if (cnt) --cnt;
else ++ans;
}
}
ans += cnt;
cout << ans << "\n";
return 0;
}