#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;
constexpr int INF = 1e9;
constexpr ll INFLL = 1e18;
constexpr int MOD = 1e9 + 7;
const ld PI = acosl(-1);
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string x;
  cin >> x;
  const int cnt = x.length() / 2 + 1;
  int ans = x.length();
  for (int _ = 0; _ < (cnt); ++_) {
    size_t pos = x.find("ST");
    if (pos == string::npos) break;
    ans -= 2;
    x = x.substr(0, pos) + x.substr(pos + 2);
  }
  cout << ans << endl;
  return 0;
}
