#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
const long long inf = 1e18;
const long long mod = 1e9 + 7;
const long long N = 2e5 + 9;
void raushan_kumar() {
  long long d = 0, e = 0, f = 0, g = 0, p = 0, w = 0, flag = 0, ans = 0,
            res = 0, cnt = 0, sum = 0;
  double f1 = 0.0, f2 = 0.0, f3 = 0.0;
  string s;
  cin >> s;
  long long n = s.length();
  while (d < n) {
    vector<long long> v;
    for (long long i = 0; i < s.length() - 1; i++) {
      if (s.substr(i, 2) == "ST") {
        v.push_back(i);
      }
    }
    for (auto i : v) {
      s.erase(s.begin() + i, s.begin() + i + 2);
    }
    d++;
  }
  cout << s.length();
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  while (t--) {
    raushan_kumar();
  }
}
