#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e7 + 17;
const int MAXN = maxn * 4;
const int darr = 1e3 + 17;
const long long INF = 1e17 + 5;
const int mod = 1e9 + 7;
void Need_For_Speed() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}
string s;
stack<char> st;
string a;
int main() {
  Need_For_Speed();
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'S') {
      a += 'S';
    } else {
      if (a[a.size() - 1] == 'S') {
        a.erase(a.size() - 1);
      } else {
        a += 'T';
      }
    }
  }
  cout << a.size();
  return 0;
}
