#include <bits/stdc++.h>
using namespace std;
bool myCmp(pair<int, int> &p1, pair<int, int> &p2) {
  return p1.first > p2.first;
}
unsigned long long choose(unsigned long long n, unsigned long long k) {
  if (k > n) {
    return 0;
  }
  unsigned long long r = 1;
  for (unsigned long long d = 1; d <= k; ++d) {
    r *= n--;
    r /= d;
  }
  return r;
}
int toInt(string str) {
  int num;
  istringstream iss(str);
  iss >> num;
  return num;
}
template <class T>
string toStr(T par) {
  ostringstream oss;
  oss << par;
  return oss.str();
}
const int MAXN = 50;
int arr[MAXN] = {0};
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  ;
  string s;
  cin >> s;
  int st = 0, ed = s.size() - 1;
  while (s[st] == 'T') st++;
  while (s[ed] == 'S') ed--;
  if (st >= ed) {
    cout << s.size() << endl;
  } else {
    int cnt_t = 0;
    int cnt_s = 0;
    for (int i = st; i <= ed; i++) {
      if (s[i] == 'S')
        cnt_s++;
      else
        cnt_t++;
    }
    cout << s.size() - 2 * min(cnt_t, cnt_s) << endl;
  }
  return 0;
}
