#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <class T>
void chmin(T &a, const T &b) noexcept {
  if (b < a) a = b;
}
template <class T>
void chmax(T &a, const T &b) noexcept {
  if (a < b) a = b;
}
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}
int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  string x;
  cin >> x;
  int n = x.length();
  int cnt = 0, preidx = 0;
  for (int i = 0; i < (n); ++i) {
    if (x[i] == 'T' && x[preidx] == 'S') {
      cnt++;
      preidx -= 1;
    } else if (i > 0)
      preidx++;
  };
  int ans = n - 2 * cnt;
  cout << ans << endl;
  return 0;
}
