#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;
const long long MOD = 1000000007;
template <class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int main() {
  string x;
  cin >> x;
  int ans = x.size();
  int s = 0;
  int t = 0;
  bool b = true;
  for (long long i = 0; i < x.size(); i++) {
    if (b && x[i] == 'S') {
      ans -= min(s, t) * 2;
      b = false;
      s = 1;
      t = 0;
    } else if (x[i] == 'S') {
      s++;
    } else {
      b = true;
      t++;
    }
  }
  ans -= min(s, t) * 2;
  cout << ans << endl;
}
