#include<bits/stdc++.h>
using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);

    string s;
    cin>>s;

    string ans;
    for (char c: s)
        if (c == 'S')   ans += c;
        else if (ans.size() && ans.back() =='S')    ans.pop_back();
        else ans += c;
    cout<<ans.size()<<endl;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
/* clang-format off */
#define MOD 1000000007
#define INF 1000000000
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
#define __DEBUG__
#ifdef __DEBUG__
#define CH_P(a) cout <<"check_point("<<#a<<")" << "\n";
#define DEBUG(x) cout<<#x<<":"<<x<<"\n"
#define DEBUGS(v) cout << #v << ":";for(auto x:v){cout<<x<<" ";}cout<<"\n"
#endif
#ifndef __DEBUG__
#define CH_P(a) 
#define DEBUG(x) 
#define DEBUGS(v) 
#endif
/* clang-format on */

int main() {
  string x;
  ll ans = 0;
  cin >> x;
  ll s = 0, t = 0;
  REP(i, x.size()) {
    if (x[i] == 'S')
      s++;
    else if (s > 0)
      s--;
    else
      ans++;
  }
  ans += s;
  cout << ans << endl;
  return 0;
}
