#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
inline bool chmin(T &a, T b) {
  if (b < a) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
T gcd(T a, T b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
template <typename T>
T lcm(T a, T b) {
  return a * (b / gcd(a, b));
}
template <typename T>
T keta(T num) {
  T k = 0;
  while (num > 0) {
    num /= 10;
    k++;
  }
  return k;
}
template <typename T>
void vdebug(vector<T> v) {
  for (auto vv : v) {
    cout << vv << " ";
  }
  cout << endl;
}
template <typename T>
void adebug(T arr[], long long n) {
  for (long long i = 0; i <= n; i++) {
    cout << arr[i] << " ";
  }
  cout << endl;
}
void ans(bool b) {
  if (b)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
void ans2(bool b) {
  if (b)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string x;
  cin >> x;
  int slen = x.length();
  long long cnt[200010];
  cnt[slen - 1] = (x[slen - 1] == 'T') ? 1 : 0;
  for (long long i = slen - 2; i >= 0; i--) {
    cnt[i] = cnt[i + 1];
    if (x[i] == 'T') cnt[i]++;
  }
  adebug(cnt, slen - 1);
  long long res = slen;
  long long used = 0;
  for (long long i = slen - 1; i >= 0; i--) {
    if (x[i] == 'T') continue;
    if (cnt[i] - used > 0) {
      res -= 2;
      used++;
    }
  }
  cout << res << endl;
  return 0;
}
