#include <bits/stdc++.h>
using namespace std;
template <class T>
T gcd(T a, T b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
template <class T>
T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}
template <class T>
string converter(T n) {
  stringstream x;
  x << n;
  return x.str();
}
string itos(int a) {
  string s = to_string(a);
  return s;
}
string itos(long long a) {
  string s = to_string(a);
  return s;
}
template <class T>
T mod_pow(T x, T n) {
  T res = 1;
  while (n > 0) {
    if (n & 1) res = res * x % 1000000007;
    x = x * x % 1000000007;
    n >>= 1;
  }
  return res;
}
std::vector<std::string> split(const std::string &str, char sep) {
  std::vector<std::string> v;
  std::stringstream ss(str);
  std::string buffer;
  while (std::getline(ss, buffer, sep)) {
    v.push_back(buffer);
  }
  return v;
}
struct edge {
  int from, to;
  long long cost;
};
int dx[] = {-1, 0, 1, 0};
int dy[] = {0, -1, 0, 1};
bool mysort(pair<int, int> a, pair<int, int> b) { return a.second < b.second; }
bool _mysort(pair<string, int> a, pair<string, int> b) {
  return a.first < b.first;
}
int main(void) {
  string s;
  cin >> s;
  ;
  auto ptr_first_s = s.find_first_of('S');
  auto ptr_last_t = s.find_last_of('T');
  ++ptr_last_t;
  long long int count_s = 0, count_t = 0;
  for (auto i = ptr_first_s; i != ptr_last_t; i++) {
    if (s[i] == 'S')
      count_s++;
    else
      count_t++;
  }
  cout << s.length() - min(count_s, count_t) * 2 << '\n';
  return 0;
}
