#include <bits/stdc++.h>
template <class T>
bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int, int>;
const int inf = 1e9 + 7;
const ll inf_l = 1e18;
const int MAX = 1e6;
int main() {
  string x;
  cin >> x;
  stack<char> s;
  for (int i = 0; i < (int)(x.size()); i++) {
    if (x[i] == 'S')
      s.push(x[i]);
    else {
      if (s.top() == 'S')
        s.pop();
      else
        s.push(x[i]);
    }
  }
  cout << s.size() << endl;
}
