#include <bits/stdc++.h>
template <typename T>
void view(T e) {
  std::cout << e << std::endl;
}
template <typename T>
void view(const std::vector<T>& v) {
  for (const auto& e : v) {
    std::cout << e << " ";
  }
  std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>>& vv) {
  for (const auto& v : vv) {
    view(v);
  }
}
using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
void Main() {
  string X;
  cin >> X;
  X += 'S';
  int res = X.length() - 1;
  int s_cnt = 0;
  int t_cnt = 0;
  for (int i = (0); i < (X.length()); ++i) {
    if (X[i] == 'S') {
      if (t_cnt > 0) {
        res -= 2 * min(s_cnt, t_cnt);
        s_cnt = 1;
        t_cnt = 0;
      } else {
        ++s_cnt;
      }
    } else {
      ++t_cnt;
    }
  }
  cout << res << endl;
}
int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
