#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
const ll linf = 1LL << 62;
const int inf = 999999;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll atcoder = int(1e9 + 7);
ll gcd(ll a, ll b) {
  if (a % b == 0)
    return b;
  else
    gcd(b, a % b);
}
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
int main() {
  string s;
  cin >> s;
  int x = s.length() / 2 + 1;
  for (int i = 0; i < x; i++) {
    for (int j = 0; j < s.length(); j++)
      if (s[j] == 'S' && s[j + 1] == 'T') s.erase(j, 2);
  }
  cout << s.length() << endl;
  return 0;
}
