#include <bits/stdc++.h>
using namespace std;
const long long inf = (long long)1e18;
const long long mod = (long long)1e9 + 7;
const double eps = (double)1e-9;
const double pi = acos(-1.0);
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};
const int N = 100500;
string s;
int n, ans, l[N], r[N];
inline void erase(int pos) {
  int nxt = r[pos];
  int prv = l[pos];
  r[prv] = nxt;
  l[nxt] = prv;
}
int main() {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  cin >> s;
  n = ans = (int)s.size();
  s = "!" + s;
  r[0] = 1;
  l[n + 1] = n;
  for (int i = 1; i <= n; i++) {
    r[i] = i + 1;
    l[i] = i - 1;
  }
  for (int i = 1; i <= n; i = r[i]) {
    if (s[i] == 'S' && s[r[i]] == 'T') {
      ans -= 2;
      int nw = l[l[i]];
      int pos1 = i;
      int pos2 = r[i];
      erase(pos1);
      erase(pos2);
      i = l[l[i]];
    }
  }
  cout << ans;
  return 0;
}
