#include <bits/stdc++.h>
using namespace std;
template <class T>
void chmax(T& a, T b) {
  if (a < b) {
    a = b;
  }
}
template <class T>
void chmin(T& a, T b) {
  if (a > b) {
    a = b;
  }
}
void YesNo(long long a) {
  if (a) {
    cout << "Yes"
         << "\n";
  } else {
    cout << "No"
         << "\n";
  }
}
void YESNO(long long a) {
  if (a) {
    cout << "YES"
         << "\n";
  } else {
    cout << "NO"
         << "\n";
  }
}
void AorB(long long a, string b, string c) {
  if (a) {
    cout << b << "\n";
  } else {
    cout << c << "\n";
  }
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
void start() {
  cin.tie(0);
  cout.tie(0);
  ios::sync_with_stdio(false);
}
signed main() {
  start();
  string s;
  cin >> s;
  long long n = s.size();
  bool check = true;
  while (check) {
    check = false;
    for (long long i = 0; i < n - 1; ++i) {
      if (s[i] == 'S' && s[i + 1] == 'T') {
        s.erase(s.begin() + i);
        s.erase(s.begin() + i);
        check = true;
      }
    }
  }
  cout << s.size() << "\n";
  return 0;
}
